Closed GHAStVHenry closed 6 years ago
Hi Gervaise, the Seurat object doesn't have a slot called genes.hvg
; as seen in the docs, FindVariableGenes
stores the variable genes in the var.genes
slot, with the means and dispersion values stored in the hvg.info
slot.
I'm sorry, I named it incorrectly, I meant var.genes.
When I just do FindVariableGenes, it populates @var.genes.
If I do FindVariableGenes after RunCCA/AlignSubspace, FindVariableGenes does NOT populate @var.genes. If I want to get the var.genes, I have to filter the @hvg.info myself.
I can't replicate that:
> data("pbmc_small")
> pbmc1 <- SubsetData(object = pbmc_small, cells.use = pbmc_small@cell.names[1:40])
> pbmc2 <- SubsetData(object = pbmc_small, cells.use = pbmc_small@cell.names[41:80])
> pbmc1@meta.data$group <- "group1"
> pbmc2@meta.data$group <- "group2"
> pbmc_cca <- RunCCA(object = pbmc1, object2 = pbmc2)
Running CCA
Merging objects
Performing log-normalization
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Scaling data matrix
|=============================================================| 100%
> pbmc_cca <- AlignSubspace(object = pbmc_cca, reduction.type = "cca", grouping.var = "group", dims.align = 1:2)
Rescaling group 1
Scaling data matrix
|=============================================================| 100%
Rescaling group 2
Scaling data matrix
|=============================================================| 100%
Aligning dimension 1
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 00s
Aligning dimension 2
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 00s
> pbmc_cca@var.genes
[1] "LTB" "EAF2" "PIK3IP1" "KHDRBS1" "SRSF7"
[6] "S1PR4" "LYAR" "SATB1" "IL17RA" "POP7"
[11] "ZNF330" "COPS6" "PPBP" "HIST1H2AC" "TALDO1"
[16] "ACRBP" "VDAC3" "GNLY" "PTGDR" "ARHGDIA"
[21] "PCMT1"
> pbmc_cca <- FindVariableGenes(object = pbmc_cca, do.plot = FALSE)
Calculating gene means
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Calculating gene variance to mean ratios
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
> pbmc_cca@var.genes
[1] "LTB" "EAF2" "CD19" "KIAA0125" "CYB561A3"
[6] "IGLL5" "PIK3IP1" "KHDRBS1" "CCR7" "ACSM3"
[11] "SRSF7" "S1PR4" "LYAR" "SATB1" "IL17RA"
[16] "POP7" "ZNF330" "COPS6" "PPBP" "PF4"
[21] "HIST1H2AC" "TALDO1" "CA2" "ACRBP" "TSC22D1"
[26] "VDAC3" "GNLY" "PTGDR" "ARHGDIA" "PCMT1"
[31] "S100B"
The var.genes
slot is different, and therefore populated by FindVariableGenes after running RunCCA/AlignSubspace.
Donno what to tell you, it's not populating for me. It's OK, I just pulled the genes by slicing the @hvg.info with my cutoffs.
Thanks, Gervaise
Ran RunCCA/AlignSubspace, then when execute FindVariableGenes, @genes.hvg results in Error: no slot of name "genes.hvg" for this object of class "seurat"
In Seurat3 it's stored at Object@assays$RNA@var.features
Ran RunCCA/AlignSubspace, then when execute FindVariableGenes, @genes.hvg results in Error: no slot of name "genes.hvg" for this object of class "seurat"
In Seurat3 it's stored at Object@assays$RNA@var.features
Where is it now in seurat 5 ?
This is probably not the most direct way but you can find this info through the meta.data using the var.features
column. If the gene was not selected as a HVG it'll be NA and if it was selected as a HVG it'll be the gene name. The following code works for me: Object@assays$RNA@meta.data$var.features[!is.na(Object@assays$RNA@meta.data$var.features)]
I am curious if there is an intended, more direct way.
var_gene <- VariableFeatures(object = OBJ_NAME)
Hi I am having some problems running MOFA because of the disappearance of the var.feature
slot in the RNA assay. Does anyone know who to create the var.feature
slot manually? Because MOFA only detects var.feature as Object@assays$RNA@var.features
not in the metadata.
I would really appreciate your help!
Thank you very much!!
Hi,
If you object has Assay5 assays you need to convert them to Assay assays. I have a helper function in my package scCustomize Convert_Assay
to make it easy. See here: https://samuel-marsh.github.io/scCustomize/articles/Object_Conversion.html#convert-seurat-assay-type-within-an-object
Best, Sam
Hi @samuel-marsh Thank you so much for your reply! I did it and it worked perfectly. :) Best!
Lucia
Hi,
I am trying to run a package but I get an error which is more about the seurat object,
error:
Error: BiocParallel errors 1 remote errors, element index: 1 0 unevaluated and other errors first remote error: Error in as.vector(x): no slot of name "var.features" for this object of class "Assay5"
I am trying to run the following package : [https://carmonalab.github.io/ProjecTILs.demo/tutorial.html] I am not sure why it is not recognising the variable. What do you suspect?
Thank you
Ran RunCCA/AlignSubspace, then when execute FindVariableGenes, @genes.hvg results in Error: no slot of name "genes.hvg" for this object of class "seurat"