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

Fix pseudo count #4111

Merged
merged 2 commits into from
Feb 22, 2021
Merged

Fix pseudo count #4111

merged 2 commits into from
Feb 22, 2021

Conversation

lldelisle
Copy link
Contributor

Hi,
Here is a bug I noticed:

library(dplyr)
library(Seurat)
library(patchwork)

# Load the PBMC dataset
pbmc.data <- Read10X(data.dir = "~/Downloads//filtered_gene_bc_matrices/hg19/")
# Initialize the Seurat object with the raw (non-normalized data).
pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k", min.cells = 3, min.features = 200)
pbmc <- NormalizeData(pbmc)
pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)
all.genes <- rownames(pbmc)
pbmc <- ScaleData(pbmc, features = all.genes)
pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))
pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 0.5)
FindMarkers(pbmc, ident.1 = 2, min.pct = 0.25,
            features = "LTB")
# It gives 1.18 as avg_log2FC
Seurat:::FindMarkers.Seurat(pbmc, ident.1 = 2, min.pct = 0.25,
                            features = "LTB", pseudocount.use = 0)
# It also gives 1.18 instead of 1.24
FoldChange(pbmc, WhichCells(pbmc, idents = 2),
           WhichCells(pbmc, idents = setdiff(Idents(pbmc), "2")),
           features = "LTB",
           pseudocount.use = 0)
# This gives 1.24
Seurat:::FindMarkers.Assay(pbmc[['RNA']], cells.1 =  WhichCells(pbmc, idents = 2),
                           cells.2 = WhichCells(pbmc, idents = setdiff(Idents(pbmc), "2")),
                           features = "LTB",
                           pseudocount.use = 0)
# This also gives 1.18 instead of 1.24

I found the error and corrected it.
Then I also noticed that if you specify mean.fxn in FindMarkers.DimReduc it was not used so I corrected it.
I hope it helps.

@timoast timoast self-requested a review February 19, 2021 21:16
@timoast
Copy link
Collaborator

timoast commented Feb 22, 2021

Thanks @lldelisle !

@timoast timoast merged commit 216e794 into satijalab:develop Feb 22, 2021
@lldelisle lldelisle deleted the fixPseudoCount branch March 18, 2021 16:43
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

Successfully merging this pull request may close these issues.

None yet

2 participants