aerickso / SpatialInferCNV

Clone Calling from Visium Spatial Transcriptomics of Cancer samples
55 stars 13 forks source link

siCNV: Spatial InferCNV from Spatial Transcriptomics Data

Spatially resolved transcriptomics has emerged as a genome-wide analysis of gene expression to explore tissues in an unsupervised manner. In this study we infer genome-wide copy-number variations (CNV) from spatially resolved mRNA profiles in situ. Gene expression has previously been used to infer CNVs in single cells, successfully identifying regions of chromosomal gain and loss. Here we expand into a spatial modality, generating CNV calls in each spatial region represented by barcoded spots.

We provide a R package via this github page, as well as scripts to reproduce the main figures in the manuscript.

This code was tested using R version 4.1.3, a Windows 11 Computer, 32GB RAM, and 12 CPUs (1.6 GHz).

For timely data-analyses of datasets comprising 2 or more Visium sections, consider use of a high performance cluster. In our project, the infercnv::run analyses steps were ran on the BMRC, with 10-20 CPUs, each 1.6 GHz and 16GB ram.

System level dependency (for the hdf5r package)

SpatialInferCNV has HDF5 as a system level dependency which needs to be installed before installing the hd5fr R package. See here for details: https://github.com/hhoeflin/hdf5r#Requirements. For Windows users, you can download the windows version here: https://github.com/mannau/h5-libwin.

Installation of SpatialInferCNV Dependencies - R

install.packages("devtools")
if (!requireNamespace("BiocManager", quietly = TRUE))
     install.packages("BiocManager")
BiocManager::install("infercnv")
install.packages("tidyverse")
install.packages("Seurat")
install.packages("phylogram")
install.packages("ape")
install.packages("hdf5r")

Installation

install.packages("devtools")
library(devtools)
install_github("aerickso/SpatialInferCNV")
library(SpatialInferCNV)

SpatialInferCNV installation via in a conda environment - MacOS or Linux

We also provide environment files to set up a conda environment in a MacOSX or Linux environment with all the dependencies necessary for SpatialInferCNV. Installation was tested using MacOS Mojave, Version 10.14.6 and an HPC running Scientific Linux 7.9. If you have anaconda installed, you can create a new environment and activate it by running the code below.

environment.yml file

conda env create -f environment.yml
conda activate SpatialInferCNV

If you want to run RStudio within this environment you can install it from the terminal with conda:

# make sure that the environment is active
conda install -c r rstudio
rstudio

Once you have created the environment you can install SpatialInferCNV.

# From R
install.packages("devtools")
library(devtools)
install_github("aerickso/SpatialInferCNV")

SpatialInferCNV installation via in a conda environment - Windows

This was tested in Anaconda3, conda version 4.12.0, on Windows 11, R version 4.1.3.

In anaconda3 terminal, create a new conda environment with R 4.1.3.

conda config --add channels conda-forge 
conda create -n siCNV r-base=4.1.3
# Select yes to install all new packages
conda activate siCNV

R

Install devtools, and configure the file download method for windows to allow install_githb() to resolve

install.packages("devtools")
library(devtools)
options(download.file.method = "wininet")

Installing R dependencies. Note: hdf5r has a system level dependency of hdf5, see above for more details.

if (!requireNamespace("BiocManager", quietly = TRUE))
     install.packages("BiocManager")
BiocManager::install("infercnv")
install.packages("tidyverse")
install.packages("Seurat")
install.packages("phylogram")
install.packages("ape")
install.packages("hdf5r")
# enter a to update/install all

library(infercnv)
library(tidyverse)
library(Seurat)
library(phylogram)
library(ape)
library(hdf5r)

After installing the R dependencies, install and initialize SpatialInferCNV.

install_github("aerickso/SpatialInferCNV")
# enter 1 to update all
# yes 
library(SpatialInferCNV)

Userguide

The package provides a number of functions, please read the user guide here.

Study Data

We provide data used in this study at the following Mendeley Repository.