This question comes up in my bioinfo class.
I have a csv file containing gene names and the cluster they belong to. I want to run GESA on each individual cluster. So I would like to extract the list of gene names corresponding to each cluster. So I wrote code like this
import pandas as pd
gene_list = pd.read_csv('marker_genes.csv')
for i in range(12):
"cluster_"+str(i) = gene_list.gene[gene_list.cluster==i]
I know this raises syntax error, so what is the correct way of doing it.
In the end, I would want cluster_0
to cluster_12
each being a list of gene names.
groupby()
function pandas.pydata.org/pandas-docs/stable/reference/api/… $\endgroup$