Tutorial on installing Seurat2 and Seurat3 simultaneously using the same version of R in Linux

Tutorial on installing Seurat2 and Seurat3 simultaneously using the same version of R in Linux

Seurat is a heavyweight R package for single-cell analysis. Everyone who has used it knows how useful it is. The Seurat analysis process basically covers all common analysis methods in single-cell analysis, including filtering, tSNE, UMAP dimensionality reduction and drawing. 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 inconsistent.

Seurat 2 is based on CCA (canonical correlation), which can correct the batch effects caused by experiments between tumors, peripheral blood and adjacent cancer tissues. It can also correct the batch effects caused by experiments using different single-cell experimental platforms. Although the speed is slow, the effect is still good. Seurat 3 makes corrections based on cell populations with similar expression profiles between samples. For experiments of the same nature, Seurat 3 can make good corrections for experimental batch effects caused by different single-cell technologies. From the pancers correction results given on the official website, you can see how powerful its correction ability is. However, due to such a powerful correction ability, the correction of tumor and peripheral blood samples was excessive, resulting in cells that should not be grouped together having similar gene expression profiles. I have also worked on several projects and found this problem in all of them, so I decisively gave up the correction method of Seurat 3 and continued to use Seurat 2. However, the findmarker function of Seurat 3 can count more than 100,000 cells at a time without error, while Seurat 2 cannot. A compromise is to install the packages of Seurat 2 and Seurat 3 at the same time, and switch data in memory instead of writing it locally and then reading it with Seurat 3 for upgrading.

Especially for tens of thousands of cells, it takes at least 30 minutes to save the data locally and 30 minutes to read it.

Now I will tell you how to switch perfectly between Seurat 2 and Seurat 3 without reading and writing locally.

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

I have 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 am using the latest R version 3.6.1 which works great.

The default library is the one that 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 between the two freely

1. First load the library where Seurat 2 is located

> .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. Detach Seurat 3 and then load Seurat 2. Because the library where Seurat 2 is located is already before Seurat 3, the system will load Seurat 2 first 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. When you want to load Seurat 3, just change the default library to the front of Seurat 2.

Isn’t it so easy?

Summarize

The above is a tutorial for installing Seurat2 and Seurat3 at the same time using the same version of R in Linux. I hope it will be helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time!

You may also be interested in:
  • How to install iso file in Linux system
  • Solve the Linux Tensorflow2.0 installation problem
  • Complete steps to install MySQL 8.0.x on Linux
  • Installing Oracle 11G in Linux virtual machine
  • Install three or more tomcats under Linux system (detailed steps)
  • How to install nginx under Linux
  • MySQL 8.0.15 installation and configuration graphic tutorial and password change under Linux

<<:  Completely uninstall mysql. Personal test!

>>:  MySQL 8.0.12 installation and configuration method graphic tutorial

Recommend

Detailed examples of the difference between methods watch and computed in Vue.js

Table of contents Preface introduce 1. Mechanism ...

Super detailed teaching on how to upgrade the version of MySQL

Table of contents 1. Introduction 2. Back up the ...

Docker deployment of Flask application implementation steps

1. Purpose Write a Flask application locally, pac...

Determine the direction of mouse entry based on CSS

In a front-end technology group before, a group m...

Implementation of Docker cross-host network (manual)

1. Introduction to Macvlan Before the emergence o...

HTML tag meta summary, HTML5 head meta attribute summary

Preface meta is an auxiliary tag in the head area...

How to set static IP for Ubuntu 18.04 Server

1. Background Netplan is a new command-line netwo...

Comparison between Redis and Memcache and how to choose

I've been using redis recently and I find it ...

Open the Windows server port (take port 8080 as an example)

What is a Port? The ports we usually refer to are...

Jmeter connects to the database process diagram

1. Download the MySQL jdbc driver (mysql-connecto...

JavaScript canvas to achieve raindrop effects

This article example shares the specific code of ...

Docker uses dockerfile to start node.js application

Writing a Dockerfile Taking the directory automat...

Solution to Django's inability to access static resources with uwsgi+nginx proxy

When deploying uwsgi+nginx proxy Django, access u...

How to install Composer in Linux

1. Download the installation script - composer-se...