Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cell type classification with or without reference integration? #9650

Open
ernohanninen opened this issue Jan 27, 2025 · 0 comments
Open

Cell type classification with or without reference integration? #9650

ernohanninen opened this issue Jan 27, 2025 · 0 comments

Comments

@ernohanninen
Copy link

Hi,
I'm confused how the cell type classification using a reference dataset with multiple batches works in Seurat version 5. In reference mapping tutorial (https://satijalab.org/seurat/articles/integration_mapping) you integrate the batches together with cca, but then you use the non integrated PCA to classify the cell types of the query. Doesn't the batch effect impact the classification in here? In the old Seurat versions the PCA was calculated for the integrated assay and the batch corrected PCA reduction was used for cell type prediction. Why has the workflow changed despite the prediction functions are the same? Or is the tutorial not up to date?

This is my code made based on tutorial. I read unintegrated data, run PCA and predict. I skip the batch correction because according to the tutorial the batch corrected PCA reduction is not used in the prediction. Is this the correct way to do it??

`
#Read and process reference data
sobj = readRDS('hypo.rds')
sobj[["RNA"]] <- split(sobj[["RNA"]], f = sobj$batch_key)
sobj <- NormalizeData(sobj)
sobj <- FindVariableFeatures(sobj,nfeatures=3000)
sobj <- ScaleData(sobj)
sobj <- RunPCA(sobj)

#Read query and predict its cell types using the reference
sobj_in_vitro = readRDS('in_vitro.rds')

features = intersect(rownames(sobj_in_vitro[['RNA']]), VariableFeatures(sobj))

transfer_anchors <- FindTransferAnchors(reference = sobj, query = sobj_in_vitro, dims = 1:15,
reference.reduction = "pca", features=features)

predictions <- TransferData(anchorset = transfer_anchors, refdata = sobj$Cell_types, dims = 1:15)

sobj_in_vitro <- AddMetaData(sobj_in_vitro, metadata = predictions)
table(sobj_in_vitro$predicted.id)

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant