I have a table like below:
Gene name 4h 12h 24h 48h
A2M 0.12 0.08 0.06 0.02
FOS 0.01 0.07 0.11 0.09
BRCA2 0.03 0.04 0.04 0.02
CPOX 0.05 0.09 0.11 0.14
I made its array like this:
import numpy as np
genelst = np.array(["A2M", "FOS", "BRCA2","CPOX"])
a2m =np.array([[0.12,0.08,0.06,0.02]])
fos = np.array([[0.01,0.07,0.11,0.09]])
brca2 = np.array([[0.03,0.04,0.04,0.02]])
cpox = np.array([[0.05,0.09,0.11,0.14]])
comb_array = np.vstack([genelst, a2m,fos,brca2,cpox])
now i want to grab that which gene has the maximum mean expression value and sort the gene names from high to low expression values?
i did:
mean_a2m = np.mean(a2m)
mean_fos = np.mean(fos)
mean_brca2 = np.mean(brca2)
mean_cpox = np.mean(cpox)
mean_expression_gene = np.vstack([[mean_a2m,mean_fos,mean_brca2,mean_cpox]])
mean_expression_gene_array = np.vstack([[genelst], [mean_a2m,mean_fos,mean_brca2,mean_cpox]])
print ("The mean expression value for A2M is:" + str(mean_a2m))
print ("The mean expression value for FOS is:" + str(mean_fos))
print ("The mean expression value for BRCA2 is:" + str(mean_brca2))
print ("The mean expression value for CPOX is:" + str(mean_cpox))
mean_expression_gene.max()
mean_expression_gene.sort()
This is just giving me the 0.0975 max value not gene name? and how to make the array understand that the gene names are the header so that it don't count its values for which i have to separate the gene names while using .max function.
Secondly, instead of using 1d array of each ( a2m, fos, brca2, cpox) for calculating average is there a way that i can get the average value of a row or a col of a 2d array in this case for comb_array?
Don't deal with multiple arrays, check how to build a dataframe