Hi I am using seurat 5.2. (I did find some similar requests but did not seem to find a solution) for info in the envornment I opened these libraries in this order:
library(dplyr)
library(Seurat)
library(patchwork)
library(scDblFinder)
library(SingleCellExperiment)
library(ggplot2)
library(future)
I have an object with 8 samples of single cell that I first merged then integrated using SCTransform and harmonyintegration parameter which I found to be best in my case. After I did subset from clusters:
Endo <- subset(x = GCharm, idents = c("Endo1", "Endo2", "Endo3", "Endo4", "Endo5", "Endo6", "EndoAdipo", "EndoLymph"))
DefaultAssay(object = Endo) <- "RNA"
Endo <- PercentageFeatureSet(Endo, pattern = "^mt-", col.name = "percent.mt")
Endo <- SCTransform(Endo, vars.to.regress = "percent.mt", verbose = FALSE)
for Sctransform function at the end, all the scaling that I need to redo after subsestting should be integrated so I guess it should be fine. I did the same for another type of cells. So in every case I get a message saying that SCT is different than the previous one that it contained (was transferred from original object during subset) which apparently from another post I found is not important. But for one of these 2 subsests I get 4 times: Warning message: In size + sum(size_args, na. rm = FALSE) : NAs produced by integer overflow is that a problem? It still continues and gives a result.
In addition for each subset object, I get an sct model list of only 1 layer/level whereas I had 8 layers standing for my 8 conditions before in my original object. I don't know why it is not separate anymore. I did try to split layers in the RNA assay before sctransform but it says they already are and I have 10 layers (including the 8 samples + counts and scale data). Should I re-do my scaling and all on the RNA assay too? I don 't think it matters for SCTransform? I was able then perform PCA, UMAP, neighbors, clusters. It's fine for one subset but for the other where I have NA errors, I get a few dots (cells) spread out in the UMAP and the main clusters with 99% of cells are then in a small corner. It does not happen with the subset without NA errors. Then, the fact that I have only 1 layer in SCTransform then generates (I think) an error in the step of integration. (I still have information of integration from the main object before subset, but I suppose it will be overwritten...?)
Note in harmony::HarmonyMatrix(data_mat = Embeddings(object = orig), :
HarmonyMatrix is deprecated and will be removed in the future from the API in the future
Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) :
Contrasts can not be applied to factors with less than 2 levels
So I tried to apply split layers:
Endo[["SCT"]] <- split(Endo[["SCT"]], f = Endo$Sample)
I get:
Note : Input is a v3 assay and split() only works for v5 assays; converting to a v5 assay
Note : Assay SCT changing from SCTAssay to Assay5
Also I note there are 24 layers which is not the 8 I expect (data x8 counts x8, scaledata x8)
then I try to integrate again
Endo <- IntegrateLayers(object = Endo, method = HarmonyIntegration, normalization.method = "SCT", verbose = F)
and I get the error message:
Error in IntegrateLayers():
! None of the features provided are found in this assay
Could you advise as to what I am doing wrong as all this code worked fine on the main object but does not work on subset object. I guess I don t subset properly or there is a step I miss after subsetting.
Why do I get NA errors in only one of my subsets Why I can't integrate anymore (how to get my normal layers back?) thanks a lot for any help,
!!!Edit:
it appears that if I first join then split layers of RNA assay first, I get the correct layers (counts and data for each sample, I had somehow lost counts layers at some point). Now when I run SCTransform I get my 8 layers again and not only 1. And now I do not have an error after integration!
I still have to resolve my NA errors.