Tutorial for installing Seurat2 and Seurat3 with the same version of R in linux

  • 2021-07-01 08:42:10
  • OfStack

As a heavyweight R package in single cell analysis, everyone who has used it knows how easy it is to use. Seurat analysis process basically covers all common analysis methods in single cell analysis, including filtering, tSNE, UMAP dimension reduction and drawing, etc. Another important function is to correct the batch effect between different experiments. However, the correction methods of Seurat 2 and Seurat 3 are completely different, and the results obtained are not the same.

Seurat 2 is based on CCA (canonical correlation), which can correct the batch effect caused by experiments among tumors, peripheral blood and adjacent tissues, and can also correct the batch effect caused by experiments with different single cell experimental platforms. Although the speed is slow, the effect is good. However, Seurat 3 is corrected based on cell groups with similar expression profiles among samples. For experiments with the same nature, seurat 3 can be well corrected due to the batch effect caused by different single cell techniques. From the correction results of pancers given by official website, we can see how powerful its correction ability is. However, due to such strong corrective ability, the correction of tumor and peripheral blood samples has gone too far, resulting in similar gene expression profiles in cells that should not be divided into one. I have also done several topics and found that there are such problems, so I decisively give up the correction method of Seurat 3 and continue to use Seurat 2. However, the findmarker function of Seurat 3 can calculate more than 100,000 cells at a time without reporting errors, while Seurat 2 can't. The compromise solution is to install Seurat 2 and Seurat 3 packages at the same time, and switch data in memory, instead of writing them locally and then reading them with Seurat 3 and upgrading them.

Especially for more than 100,000 cells, it takes at least 30min to save data locally and 30min to read it.

Let me tell you that you can switch between Seurat 2 and Seurat 3 perfectly without reading and writing locally.

In fact, the method is very simple, just install Seurat 2 and Seurat 3 in different library.

I have already installed it. Take my own free switching as an example:


> R.version
        _             
platform    x86_64-conda_cos6-linux-gnu
arch      x86_64           
os       linux-gnu         
system     x86_64, linux-gnu     
status                  
major     3             
minor     6.1            
year      2019            
month     07             
day      05             
svn rev    76782           
language    R             
version.string R version 3.6.1 (2019-07-05)
nickname    Action of the Toes  

I'm using the latest R version 3.6. 1, which works well.

The default library comes with conda


> .libPaths()
[1] "/data/home/heshuai/anaconda3/lib/R/library"

The default Seurat is the latest version of Seurat 3


> library(Seurat)
Registered S3 method overwritten by 'R.oo':
 method    from   
 throw.default R.methodsS3
> packageVersion("Seurat")
[1]  ' 3.0.2'

I installed Seurat 2 in another library


/data/home/heshuai/R/x86_64-conda_cos6-linux-gnu-library

Switch freely between the two

1. First load the library where Seurat 2 resides


> .libPaths("/data/home/heshuai/R/x86_64-conda_cos6-linux-gnu-library")
> .libPaths()
[1] "/data/home/heshuai/R/x86_64-conda_cos6-linux-gnu-library" "/data/home/heshuai/anaconda3/lib/R/library"      
>

2. Load Seurat 2 after detach Seurat 3, because the library where Seurat 2 is located is already before Seurat 3, and the system will load Seurat 2 by default


> detach("package:Seurat", unload = T)
> library(Seurat)
Loading required package: ggplot2
RStudio Community is a great place to get help: https://community.rstudio.com/c/tidyverse.
Loading required package: cowplot
 
********************************************************
Note: As of version 1.0.0, cowplot does not change the
 default ggplot2 theme anymore. To recover the previous
 behavior, execute:
 theme_set(theme_cowplot())
********************************************************
 
Loading required package: Matrix
> packageVersion("Seurat")
[1]  ' 2.3.4'
>    

Now Seurat 3 has been successfully switched to Seurat 2. To load Seurat 3, change the default library to the front of Seurat 2.

Is it so easy!  

Summarize

The above is the site introduced to you in linux with the same version of R installation of Seurat2 and Seurat3 tutorials, I hope to help you, if you have any questions welcome to give me a message, this site will reply to you in time!


Related articles: