Skip to content

Commit a52af88

Browse files
authored
Merge pull request #10 from AlexandrovLab/development
Add CNV and SV support for R version
2 parents 3ccb446 + 9bf45a0 commit a52af88

15 files changed

+35170
-38
lines changed

.DS_Store

-10 KB
Binary file not shown.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.Rhistory
33
.RData
44
.Ruserdata
5+
**/.DS_Store

.travis.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
language: R
1+
dist: xenial
2+
language: r
3+
latex: false
24

3-
sudo: false
4-
cache: packages
5-
warnings_are_errors: false
65
r:
7-
- release
8-
- devel
6+
- release
7+
8+
addons:
9+
apt:
10+
packages:
11+
- libharfbuzz-dev
12+
- libfribidi-dev
13+
14+
cache:
15+
packages: true
16+
17+
warnings_are_errors: false
18+
19+
script: R -f test.R

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: SigProfilerMatrixGeneratorR
22
Type: Package
33
Title: An R wrapper for running the SigProfilerMatrixGenerator framework
4-
Version: 0.1.0
4+
Version: 1.2.13
55
Author: Erik Bergstrom
66
Maintainer: Erik Bergstrom <ebergstr@eng.ucsd.edu>
77
Description: SigProfilerMatrixGenerator creates mutational matrices for all types of somatic mutations.

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export(SigProfilerMatrixGeneratorR)
2+
export(CNVMatrixGenerator)
3+
export(SVMatrixGenerator)
24
export(install)
35
import(devtools)
46
import(reticulate)

R/SigProfilerMatrixGeneratorR.R

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,38 @@
99
#' @examples
1010
#'
1111
#' @export SigProfilerMatrixGeneratorR
12-
1312
SigProfilerMatrixGeneratorR <- function(project, genome, matrix_path, exome=F, bed_file=NULL, chrom_based=F, plot=F, tsb_stat=F, seqInfo=F, cushion=100, gs=F) {
1413
os <- reticulate::import("os")
1514
sys <- reticulate::import("sys")
1615

1716
matGen <- reticulate::import("SigProfilerMatrixGenerator.scripts.SigProfilerMatrixGeneratorFunc")
17+
18+
1819
matrices <- matGen$SigProfilerMatrixGeneratorFunc(project, genome, matrix_path, exome, bed_file, chrom_based, plot, tsb_stat, seqInfo, cushion, gs)
20+
21+
1922
sys$stdout$flush()
2023
return(matrices)
2124
}
2225

26+
#' @export CNVMatrixGenerator
27+
CNVMatrixGenerator <- function(file_type, input_file, project, output_path) {
28+
cnv <- reticulate::import("SigProfilerMatrixGenerator.scripts.CNVMatrixGenerator")
29+
cnv_matrices <- cnv$generateCNVMatrix(file_type, input_file, project, output_path)
30+
sys$stdout$flush()
31+
return(cnv_matrices)
32+
33+
}
34+
35+
#' @export SVMatrixGenerator
36+
SVMatrixGenerator <- function(input_dir, project, output_dir) {
37+
sv <- reticulate::import("SigProfilerMatrixGenerator.scripts.SVMatrixGenerator")
38+
sv_matrices <- sv$generateSVMatrix(input_dir, project, output_dir)
39+
sys$stdout$flush()
40+
return(sv_matrices)
41+
42+
}
43+
2344
#' @export install
2445
install <- function(genome, custom=F, rsync=F, bash=T, ftp=T){
2546
os <- reticulate::import("os")

README.md

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,39 @@ The purpose of this document is to provide a guide for using the SigProfilerMatr
1111

1212
**PREREQUISITES**
1313

14-
devtools (R)
15-
```
14+
devtools (R)
15+
```R
1616
>> install.packages("devtools")
1717
```
18-
reticulate* (R)
19-
```
18+
19+
reticulate* (R)
20+
```R
2021
>> install.packages("reticulate")
2122
```
2223

2324
*Reticulate has a known bug of preventing python print statements from flushing to standard out. As a result, some of the typical progress messages are delayed.
2425

26+
Alternatively, you can set up a conda environment with all the prerequisites. You can download minicoda for your operating system [here](https://docs.conda.io/en/latest/miniconda.html) and follow the instructions below:
27+
28+
```
29+
conda create --name spmg_r -y
30+
conda activate spmg_r
31+
conda install python=3.10 r-base r-devtools r-reticulate -c conda-forge -y
32+
```
33+
2534
**QUICK START GUIDE**
2635

2736
This section will guide you through the minimum steps required to create mutational matrices:
2837
1. First, install the python package using pip. The R wrapper still requires the python package:
38+
2939
```
30-
pip install SigProfilerMatrixGenerator
40+
pip install SigProfilerMatrixGenerator
3141
```
3242
2. Open an R session and ensure that your R interpreter recognizes the path to your python3 installation:
33-
```
43+
```R
3444
$ R
35-
>> library("reticulate")
36-
>> use_python("path_to_your_python3")
45+
>> library(reticulate)
46+
>> use_python("[path_to_your_python3]") # if using conda the path will be [path_to_your_conda]/envs/spmg_r/bin/python
3747
>> py_config()
3848
python: /anaconda3/bin/python3
3949
libpython: /anaconda3/lib/libpython3.6m.dylib
@@ -42,15 +52,17 @@ version: 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) [GCC 4.
4252
numpy: /anaconda3/lib/python3.6/site-packages/numpy
4353
numpy_version: 1.16.1
4454
```
55+
4556
If you do not see your python3 path listed, restart your R session and rerun the above commands in order.
4657

4758
2. Install SigProfilerMatrixGeneratorR using devtools:
48-
```
49-
>>library("devtools")
59+
```R
60+
>>library(devtools)
5061
>>install_github("AlexandrovLab/SigProfilerMatrixGeneratorR")
5162
```
63+
5264
3. Load the package in the same R session and install your desired reference genome as follows (available reference genomes are: GRCh37, GRCh38, mm9, and mm10):
53-
```
65+
```R
5466
>> library("SigProfilerMatrixGeneratorR")
5567
>> install('GRCh37', rsync=FALSE, bash=TRUE)
5668
```
@@ -60,29 +72,47 @@ This will install the human 37 assembly as a reference genome.
6072
4. Place your vcf files in your desired output folder. It is recommended that you name this folder based on your project's name
6173

6274
5. From within the same R session, you can now generate the matrices as follows:
63-
```
75+
76+
****SBS/DBS/ID****
77+
```R
6478
>> library("SigProfilerMatrixGeneratorR")
65-
>> matrices <- SigProfilerMatrixGeneratorR("BRCA", "GRCh37", "/Users/ebergstr/Desktop/BRCA/", plot=T, exome=F, bed_file=NULL, chrom_based=F, tsb_stat=False, seqInfo=False, cushion=100)
79+
>> matrices <- SigProfilerMatrixGeneratorR("test_SBS", "GRCh37", "[path_to_repo]/test_data/SBS", plot=T, exome=F, bed_file=NULL, chrom_based=F, tsb_stat=False, seqInfo=False, cushion=100)
6680
```
81+
6782
The layout of the required parameters are as follows:
68-
69-
SigProfilerMatrixGeneratorFunc(project, reference_genome, path_to_input_files)
70-
83+
84+
```R
85+
SigProfilerMatrixGeneratorFunc(project, reference_genome, path_to_input_files)
86+
```
87+
7188
where project, reference_genome, and path_to_input_files must be strings (surrounded by quotation marks, ex: "test"). Optional parameters include:
72-
89+
90+
7391
exome=FALSe: [boolean] Downsamples mutational matrices to the exome regions of the genome
74-
bed_file=NULL [string path to bed_file] Downsamples mutational matrices to custom regions of the genome. Requires the full path to the BED file.
92+
bed_file=NULL [string path to bed_file] Downsamples mutational matrices to custom regions of the genome. Requires the full path to the BED file.
7593
chrom_based=FALSE [boolean] Outputs chromosome-based matrices
76-
plot=FALSE [boolean] Integrates with SigProfilerPlotting to output all available visualizations for each matrix.
77-
tsb_stat=FALSE [boolean] Outputs the results of a transcriptional strand bias test for the respective matrices.
78-
seqInfo=FALSE [boolean] Ouputs original mutations into a text file that contains the SigProfilerMatrixGenerator classificaiton for each mutation.
79-
cushion=100 [integer] Adds an Xbp cushion to the exome/bed_file ranges for downsampling the mutations.
80-
94+
plot=FALSE [boolean] Integrates with SigProfilerPlotting to output all available visualizations for each matrix.
95+
tsb_stat=FALSE [boolean] Outputs the results of a transcriptional strand bias test for the respective matrices.
96+
seqInfo=FALSE [boolean] Ouputs original mutations into a text file that contains the SigProfilerMatrixGenerator classificaiton for each mutation.
97+
cushion=100 [integer] Adds an Xbp cushion to the exome/bed_file ranges for downsampling the mutations.
98+
99+
100+
****CNV****
101+
```R
102+
>> library("SigProfilerMatrixGeneratorR")
103+
>> matrix_cnv <- CNVMatrixGenerator("BATTENBERG", "[path_to_repo]/test_data/CNV", "test_CNV", "output_dir_CNV")
104+
```
105+
106+
****SV****
107+
```R
108+
>> library("SigProfilerMatrixGeneratorR")
109+
>> matrix_sv <- SVMatrixGenerator("[path_to_repo]/test_data/SV", "test_SV", "output_dir_SV")
110+
```
81111

82112

83113
**INPUT FILE FORMAT**
84114

85-
This tool currently supports maf, vcf, simple text file, and ICGC formats. The user must provide variant data adhering to one of these four formats. If the user’s files are in vcf format, each sample must be saved as a separate files.
115+
This tool currently supports maf, vcf, simple text file, and ICGC formats. The user must provide variant data adhering to one of these four formats. If the user’s files are in vcf format, each sample must be saved as a separate files.
86116

87117

88118
**Output File Structure**
@@ -99,20 +129,20 @@ GRCh38.p12 [GRCh38] (Genome Reference Consortium Human Reference 37), INSDC
99129
Assembly GCA_000001405.27, Dec 2013. Released July 2014. Last updated January 2018. This genome was downloaded from ENSEMBL database version 93.38.
100130

101131
GRCh37.p13 [GRCh37] (Genome Reference Consortium Human Reference 37), INSDC
102-
Assembly GCA_000001405.14, Feb 2009. Released April 2011. Last updated September 2013. This genome was downloaded from ENSEMBL database version 93.37.
132+
Assembly GCA_000001405.14, Feb 2009. Released April 2011. Last updated September 2013. This genome was downloaded from ENSEMBL database version 93.37.
103133

104134
GRCm38.p6 [mm10] (Genome Reference Consortium Mouse Reference 38), INDSDC
105-
Assembly GCA_000001635.8, Jan 2012. Released July 2012. Last updated March 2018. This genome was downloaded from ENSEMBL database version 93.38.
135+
Assembly GCA_000001635.8, Jan 2012. Released July 2012. Last updated March 2018. This genome was downloaded from ENSEMBL database version 93.38.
106136

107137
GRCm37 [mm9] (Release 67, NCBIM37), INDSDC Assembly GCA_000001635.18.
108138
Released Jan 2011. Last updated March 2012. This genome was downloaded from ENSEMBL database version release 67.
109139

110-
rn6 (Rnor_6.0) INSDC Assembly GCA_000001895.4, Jul 2014. Released Jun 2015. Last updated Jan 2017.
140+
rn6 (Rnor_6.0) INSDC Assembly GCA_000001895.4, Jul 2014. Released Jun 2015. Last updated Jan 2017.
111141
This genome was downloaded from ENSEMBL database version 96.6.
112142

113143
**LOG FILES**
114144

115-
All errors and progress checkpoints are saved into *sigProfilerMatrixGenerator_[project]_[genome].err* and *sigProfilerMatrixGenerator_[project]_[genome].out*, respectively.
145+
All errors and progress checkpoints are saved into *sigProfilerMatrixGenerator_[project]_[genome].err* and *sigProfilerMatrixGenerator_[project]_[genome].out*, respectively.
116146
For all errors, please email the error and progress log files to the primary contact under CONTACT INFORMATION.
117147

118148
**CITATION**
@@ -132,8 +162,9 @@ Redistributions of source code must retain the above copyright notice, this list
132162

133163
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
134164

135-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
165+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
136166

137167
**CONTACT INFORMATION**
138168

139-
Please address any queries or bug reports to Erik Bergstrom at ebergstr@eng.ucsd.edu
169+
Please address any queries or bug reports for SBS/ID/DBS to Erik Bergstrom at ebergstr@eng.ucsd.edu
170+
Please address any queries or bug reports for CNV/SV to Azhar Khandekar at akhandek@eng.ucsd.edu

man/.Rapp.history

Whitespace-only changes.

man/CNVMatrixGenerator.Rd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
\name{CNVMatrixGenerator}
2+
\alias{CNVMatrixGenerator}
3+
\title{CNVMatrixGenerator}
4+
\usage{
5+
CNVMatrixGenerator()
6+
}
7+
\description{
8+
Creates CNV matrix.
9+
}

man/SVMatrixGenerator.Rd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
\name{SVMatrixGenerator}
2+
\alias{SVMatrixGenerator}
3+
\title{SVMatrixGenerator}
4+
\usage{
5+
SVMatrixGenerator()
6+
}
7+
\description{
8+
Creates SV matrix.
9+
}

test.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library(devtools)
2+
install_github("AlexandrovLab/SigProfilerMatrixGeneratorR@development")
3+
4+
library(SigProfilerMatrixGeneratorR)

0 commit comments

Comments
 (0)