目前,如果你還是編程小白!!
你諮詢編程大神:大神、大神,我想學編程,你說我是學Java、C語言、Python..,還是其他的語言?你推薦先學哪一種程式語言呢?.。
問題就如糖衣大炮一樣,又讓人應接不暇,無從下口。但是,大多數大神給你的回答就是學python,我前面也寫過一篇博文為什麼推薦學Python。首先,Python語法讀起來還是比較簡單的,類似於R語言一樣,以及Python的用途很廣等等因素結合起來,所以推薦小白的你來學Python。
但是說來慚愧,自己很早以前就一直有這個概念,有這樣的想法,但是由於自己一直沒有堅持下來,到現在還是不會寫Python代碼,慚愧,羞愧,害...,沒有臉說什麼吧。我自己也是個編程小白。
生信人,最少需要來掌握一門程式語言(PS:自己定義R語言不算,個人認為R是必須掌握的)。個人推薦,Perl或Python可以適當學一點哦!至少可以滿足自己需求,如果你不會,那只能求助他人啦(滿足這個條件的前提是,你身邊有這樣的大神)。
OK!!前面都是些「廢話」,我後續也會逐漸的分享一些關於Python的教程。
我們一起進步啦!!一起學習!!
今天分享的教程是,求所有數據的標準差和均值
代碼來自Nature Methods,題目OME-NGFF: a next-generation file format for expanding bioimaging data-access strategies,網址:https://www.nature.com/articles/s41592-021-01326-w#data-availabilit
1.1 原始數據代碼區
## python
# Get the standard deviation and mean for all the benchmark data
# grouped by type (e.g. HDF5, TIFF, Zarr, Overhead) and by
# source (e.g. http, local, s3)
## 加載所需包
import pandas
# 加載我文件
for csv_file in ["2d_benchmark_data.csv", "3d_benchmark_data.csv"]:
print(csv_file)
df = pandas.read_csv(csv_file)
print("Mean")
mean_values = df.groupby(["type", "source"]).mean()
# or if you only want the "seconds" column
# mean_values = mean_values["seconds"]
print(mean_values)
print("Std")
std_values = df.groupby(["type", "source"]).std()
print(std_values)代碼分段式
for csv_file in ["2d_benchmark_data.csv", "3d_benchmark_data.csv"]:
print(csv_file)求均值
df = pandas.read_csv(csv_file)
print("Mean")
mean_values = df.groupby(["type", "source"]).mean()輸出結果如下:
2d_benchmark_data.csv
Mean
type source
HDF5 http 0.221113
local 0.002818
s3 1.121805
Overhead http 0.001269
local 0.000014
s3 0.011279
TIFF http 0.151114
local 0.086267
s3 0.388272
Zarr http 0.006652
local 0.007099
s3 0.131575
Name: seconds, dtype: float64
Std
duration chunk_distance round seconds
type source
HDF5 http 0.051123 149981.733567 29.011492 0.051115
local 0.004189 149981.733567 29.011492 0.004156
s3 0.322672 149981.733567 29.011492 0.322666
Overhead http 0.001197 149981.733567 29.011492 0.001187
local 0.000016 149981.733567 29.011492 0.000002
s3 0.002839 149981.733567 29.011492 0.002838
TIFF http 0.037332 149981.733567 29.011492 0.037327
local 0.036226 149981.733567 29.011492 0.036227
s3 0.088530 149981.733567 29.011492 0.088532
Zarr http 0.001773 149981.733567 29.011492 0.001760
local 0.002866 149981.733567 29.011492 0.002868
s3 0.019592 149981.733567 29.011492 0.019609
3d_benchmark_data.csv
Mean
type source
HDF5 http 0.220592
local 0.002479
s3 1.046130
Overhead http 0.001163
local 0.000023
s3 0.012607
TIFF s3 0.928801
Zarr http 0.013290
local 0.007667
s3 0.100552
Name: seconds, dtype: float64
Std
duration chunk_distance round seconds
type source
HDF5 http 0.051433 906299.64163 29.011492 0.051430
local 0.002911 906299.64163 29.011492 0.002880
s3 0.259094 906299.64163 29.011492 0.259042
Overhead http 0.000518 906299.64163 29.011492 0.000509
local 0.000086 906299.64163 29.011492 0.000051
s3 0.005196 906299.64163 29.011492 0.005179
TIFF s3 NaN NaN NaN NaN
Zarr http 0.009346 906299.64163 29.011492 0.009336
local 0.006391 906299.64163 29.011492 0.006381
s3 0.015169 906299.64163 29.011492 0.015172
Process finished with exit code 0初學者,很多不懂,請大家多多指教!!
一起進步哦!!!
「小杜的生信筆記」 公眾號、知乎、簡書,主要發表或收錄生物信息學的教程,以及基於R的分析和可視化(包括數據分析,圖形繪製等);分享感興趣的文獻和學習資料!