fabilab / northstar

Single cell type annotation guided by cell atlases, with freedom to be queer
https://northstar.readthedocs.io/
MIT License
25 stars 6 forks source link

how to annotation the celltype using the extracted the result #2

Closed ChenchenWangiSummer closed 4 years ago

ChenchenWangiSummer commented 4 years ago

Hi, all I try to use the northstar to annotate my single cell dataset following the Tutorial:

...
af = northstar.AtlasFetcher()
af.list_atlases()
myatlas = af.fetch_atlas('Darmanis_2015_nofetal', kind='subsample')
cell_types_ns = model.membership
pd.DataFrame(cell_types_ns).to_csv("/Users/.../..celltype.csv")

but when i open the ..csv, i just see the numbers:

  0
0 18
1 17
2 17
3 17
4 17
5 17
6 17
7 17
8 17
9 17
10 17
11 17
12 17
13 17

....

is this right? how could i get the right celltype annotation into my adata in the scanpy?

many thanks! CC

iosonofabio commented 4 years ago

Hi CC,

Please include the whole code you wanna run. You're clearly skipping some chunks in the code above since you never call the model constructor and fit function...

ChenchenWangiSummer commented 4 years ago

Hi iosonofabio, this is my whole code:

import northstar
import scanpy as sc

# Choose atlas
af = northstar.AtlasFetcher()
af.list_atlases()
myatlas = af.fetch_atlas('Darmanis_2015_nofetal', kind='subsample')

# atlas = 'Darmanis_2015_nofetal'
# Prepare classifier
model = northstar.Subsample(
    atlas=myatlas,
    )
adata = sc.read('/Users/wangchenchen/data/single_cell2/downstream/LZ003_final.loom', validate=False)
#dataset = anndata.read_loom('/Users/wangchenchen/data/single_cell2/downstream/LZ003_aucell.loom', sparse=False)

# Run classifier
model.fit(adata)

# Extract result
cell_types_ns = model.membership

embedding = model.embed(method='umap')
pd.DataFrame(cell_types_ns).to_csv("/Users/wangchenchen/data/single_cell2/downstream/LZ003_celltype.csv")

Hi CC,

Please include the whole code you wanna run. You're clearly skipping some chunks in the code above since you never call the model constructor and fit function...

iosonofabio commented 4 years ago

model.membership is a pandas Series:

You could use "model.embed()" to get a sense of what's going on.

ChenchenWangiSummer commented 4 years ago

OK, so the northstar can not give the cell names if I am not setting cell names?

model.membership is a pandas Series:

  • The index is our cell names. You are not setting your cell names so they end up being strings that look like numbers - you probably wanna fix that in your loom reading step.
  • The values is the clusters. If you get numbers, it means they are new clusters compared to the atlas. In other words, your cells "as are" look very different from the transcriptome profiles in that atlas.

You could use "model.embed()" to get a sense of what's going on.

iosonofabio commented 4 years ago

I'm not sure what you mean. How could northstar know your cell names? It only knows about cell types, from the atlas

ChenchenWangiSummer commented 4 years ago

@iosonofabio sorry, I mean can I using the northstar to get the results of my cell type annotation information as the index in the output file?

iosonofabio commented 4 years ago

@ChenchenWangiSummer I recommend you seek advice from a more experienced data analyst, your questions appear to be a little uninformed. Closing.