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

Encountering problems with selectFeatures #30

Open
sagnikbanerjee15 opened this issue Jul 8, 2021 · 1 comment
Open

Encountering problems with selectFeatures #30

sagnikbanerjee15 opened this issue Jul 8, 2021 · 1 comment

Comments

@sagnikbanerjee15
Copy link

Hello,

I am trying to use scTransformed counts instead of log-transformed counts for training and predicting cell types. I created a Seurat object, performed the sctranform and then created a SingleCellExperiment object from the sctransformed counts. The execution fails at this line:
sce_with_sctransformed_counts <- selectFeatures(sce_with_sctransformed_counts, suppress_plot = TRUE), producing the following error:

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
  0 (non-NA) cases
In addition: Warning message:
In linearModel(object, n_features) :
  Your object does not contain counts() slot. Dropouts were calculated using logcounts() slot...

It does not seem like there are any NA values in the logcounts

any(is.na(logcounts(sce_with_sctransformed_counts)))
[1] FALSE

I suspected that since the sctransformed values are negative, it could be a potential source of error. Hence, I executed the following:

logcounts(sce_with_sctransformed_counts) <- log2(normcounts(sce_with_sctransformed_counts) + 5)

But I still keep getting the same error.

Could you please help me with this?

This is a portion of the code I am using.

sce_seurat <- CreateSeuratObject(counts = Data[,Train_Idx[[i]]])
sce_seurat <- SCTransform(object = sce_seurat)
sce_with_sctransformed_counts = SingleCellExperiment(assays = list(normcounts = GetAssayData(object = sce_seurat, slot = "scale.data")), 
colData = data.frame(cell_type1 = Labels[Train_Idx[[i]]]))
rowData(sce_with_sctransformed_counts)$feature_symbol <- rownames(sce_with_sctransformed_counts)
logcounts(sce_with_sctransformed_counts) <- log2(normcounts(sce_with_sctransformed_counts) + 5)			
sce_with_sctransformed_counts <- selectFeatures(sce_with_sctransformed_counts, suppress_plot = TRUE)

Thank you.

@mhemberg
Copy link

mhemberg commented Jul 8, 2021

Did you try to create the counts slot instead of the logcounts? Also, I assume that negative values would have a small magnitude and be relatively few, but did you check how many of them you have after doing the normalization with sctransform?

As you point out, we do make the assumption that counts are non-negative and as sctransform was published after scmap we were not able to test this combination (which does seem quite useful so I am curious to see how well it works).

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

2 participants