I am trying to use the Scanpy Python package to analyze some single-cell data. I read a count matrix (a .tsv file) in as a Pandas data frame, which has genes as the columns and rows as the different cells. Each row contains the counts for the different genes for a single cell. I would like to create an AnnData object from the Pandas data frame... does anyone know how I can do this? Unfortunately, I cannot provide the dataset.
How do I create AnnData object from a pandas data frame count matrix?
14.8k views Asked by AyeTown At
3
You can convert your DataFrame
df
into AnnDataadata
this way:But you don't really need to do that. Instead, directly read the tsv file into an AnnData object: