SingleR-inc / SingleR

Clone of the Bioconductor repository for the SingleR package.
https://bioconductor.org/packages/devel/bioc/html/SingleR.html
GNU General Public License v3.0
165 stars 19 forks source link

Example of using harmonised labels for `de.method="wilcox"` instead of classic marker detection #247

Open denvercal1234GitHub opened 9 months ago

denvercal1234GitHub commented 9 months ago

Hi there,

Thanks again for a great package.

In the tutorial (https://bioconductor.org/books/release/SingleRBook/using-multiple-references.html#using-harmonized-labels), the gene from references are determined via getClassicMarkers() for use when de.method="classic".

com.markers <- getClassicMarkers(
    ref = list(BPE=bpe.ont, HPCA=hpca.ont), 
    labels = list(bpe.ont$label.ont, hpca.ont$label.ont))

com.res3b <- SingleR(test = pbmc, assay.type.test=1,
    ref = list(BPE=bpe.ont, HPCA=hpca.ont), 
    labels = list(bpe.ont$label.ont, hpca.ont$label.ont),
    genes = list(com.markers, com.markers))

table(Label=com.res3b$labels, Reference=com.res3b$reference)

Q1. If I want to use de.method="wilcox", would you mind giving me how to modify the code?

Q2. And, is it appropriate to use com.markers from getClassicMarkers() in `SingleR(... de.method="wilcox"...) or really com.markers should only be used for de.method="classic"?

Thank you again!

LTLA commented 9 months ago

Q1. If I want to use de.method="wilcox", would you mind giving me how to modify the code?

de.method="wilcox" just uses genes derived from scran::findMarkers. Basically something like:

pairwise <- pairwiseWilcox(x = ref, groups = labels, direction = "up", log.p = TRUE)
collected <- scran::getTopMarkers(pairwise$statistics, pairwise$pairs,
    n = 10, pval.field = "log.p.value", fdr.field = "log.FDR", fdr.threshold = log(0.05))
lapply(collected, as.list)

(Adapted from SingleR:::.get_genes_by_de, which is what trainSingleR calls under the hood.)

This will give you a list of lists of markers that is comparable to the output of getClassicMarkers.

Q2. And, is it appropriate to use com.markers from getClassicMarkers() in `SingleR(... de.method="wilcox"...) or really com.markers should only be used for de.method="classic"?

If you give genes=, any setting of de.method= will be ignored.