Seurat: any experience on using Seurat to process MAGIC imputation data?

Created on 12 Jul 2018  路  7Comments  路  Source: satijalab/seurat

Hi,

I want to use MAGIC imputation's result to do RunMultiCCA in Seurat. Here is the problem,

I have serveral samples, and I can sucessfully run RunMultiCCA for them. After that, I use the raw.data slot as input for running MAGIC imputation, then using CreatSeuratObject to process MAGIC output data into a new Seurat object. Then I use SubSetData to generate several objects and RunMultiCCA again. but it always report error (something like subscription out of bound). Is this caused by those negtive value in the MAGIC dataframe? Woud you please give any suggestion on it?

Thank you very much.
Best wishes!

Most helpful comment

  1. For your specific problem, I'm not sure if its related to MAGIC. When you run SubsetData, try setting do.clean=T.

  2. For anyone interested in running MAGIC followed by Seurat, here is a quick example. Note that there is always some inherent danger in oversmoothing the data by running dimensional reduction techniques like PCA, after having performed smoothing/imputation.

data <- as.matrix(t(pbmc@data))
MAGIC_data <- magic(data[,[email protected]], [email protected])

#create an identical object, and set the @data slot to the MAGIC values
pbmc2 <- pbmc
pbmc2@data <- t(MAGIC_data$result)
pbmc2 <- ScaleData(pbmc2)
pbmc2 <- RunPCA(pbmc2)
pbmc2 <- RunTSNE(pbmc2,dims.use = 1:10)
TSNEPlot(pbmc2)

All 7 comments

  1. For your specific problem, I'm not sure if its related to MAGIC. When you run SubsetData, try setting do.clean=T.

  2. For anyone interested in running MAGIC followed by Seurat, here is a quick example. Note that there is always some inherent danger in oversmoothing the data by running dimensional reduction techniques like PCA, after having performed smoothing/imputation.

data <- as.matrix(t(pbmc@data))
MAGIC_data <- magic(data[,[email protected]], [email protected])

#create an identical object, and set the @data slot to the MAGIC values
pbmc2 <- pbmc
pbmc2@data <- t(MAGIC_data$result)
pbmc2 <- ScaleData(pbmc2)
pbmc2 <- RunPCA(pbmc2)
pbmc2 <- RunTSNE(pbmc2,dims.use = 1:10)
TSNEPlot(pbmc2)

Hi,

Thanks for the quick example. Can you please comment on the pros/cons of recalculating clusters on the smoothed data?

Thanks,
Alex

As a note to anyone looking to use MAGIC on a Seurat object, as of Rmagic v1.4.0 MAGIC now accepts a Seurat object and returns it natively as described above, so the workflow is simply:

pbmc <- CreateSeuratObject(...)
pbmc <- ScaleData(pbmc)
MAGIC_pbmc <- magic(pbmc, [email protected])
# or MAGIC_pbmc <- magic(pbmc, genes="all_genes")
MAGIC_pbmc <- RunPCA(MAGIC_pbmc )
MAGIC_pbmc <- RunTSNE(MAGIC_pbmc ,dims.use = 1:10)
TSNEPlot(MAGIC_pbmc)

Since RunPCA() uses scaled data, shouldn't ScaleData() be after magic(), not before?

Any equivalent for Seurat v3?

@kvshams there's an S3 method in Rmagic if you install from GitHub:

devtools::install_github("KrishnaswamyLab/MAGIC", subdir='Rmagic')

With this latest version you can just call magic(seurat_obj) and the imputed matrix will be added as an assay named MAGIC_RNA (if you assay is named RNA).

I'm currently working on getting this on CRAN.

@igordot

Since RunPCA() uses scaled data, shouldn't ScaleData() be after magic(), not before?

I had this same question. The PCA in Magic (and all steps) pulls from the 'data' slot of your default assay (presumably "RNA"). Thus, whatever happens with ScaleData and scale.data slot should be independent of what's going on with magic.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

milanmlft picture milanmlft  路  3Comments

kysbbubbu picture kysbbubbu  路  3Comments

mvalenzuelav picture mvalenzuelav  路  3Comments

kathirij picture kathirij  路  3Comments

tmccra2 picture tmccra2  路  3Comments