ソースを参照

修改input文件中的docker和workDir

master
ISCAP 6年前
コミット
bafffa12ef
5個のファイルの変更181行の追加6行の削除
  1. +9
    -0
      Docker/Dockerfile
  2. +140
    -0
      Docker/cn.mops.R
  3. +28
    -0
      Docker/cn_mops
  4. +2
    -3
      inputs
  5. +2
    -3
      tasks/cn_mops.wdl

+ 9
- 0
Docker/Dockerfile ファイルの表示

@@ -0,0 +1,9 @@
FROM choppy/bioconductor-cn.mops:1.16.2

COPY . /opt/mops
RUN chmod a+x /opt/mops/cn_mops
RUN ln -s /opt/mops/cn_mops /bin

WORKDIR /data/

CMD ["ls", "-al", "/opt"]

+ 140
- 0
Docker/cn.mops.R ファイルの表示

@@ -0,0 +1,140 @@
###################
## cn.mops ##
## Jiyang Zhang ##
## 2019.01.21 ##
###################
#
#1 Introduction
##The cn.mops package is part of the Bioconductor (http://www.bioconductor.org) project.
##The package allows to detect copy number variations (CNVs) from next generation sequencing (NGS) data sets based on a generative model.
##Please visit http://www.bioinf.jku.at/software/cnmops/cnmops.htmlfor additional information.
#
#2 Set up
#
##2.1 load package
library(cn.mops) #cn.mops_1.16.2
#
##2.2 load options
#
###2.2.1 Collect arguments
args <- commandArgs(TRUE)
#
###2.2.2 Help section
#### Default setting when no arguments passed
if(length(args) < 1) {
args <- c("--help")
}
#### Help section
if("--help" %in% args) {
cat("
The R Script
Arguments:
--Tumor=the name of the TUMOR sample BAMfile - string
--Normal=the name of the NORMAL sample BAMfile - string
--TumorSampleID=the name of the TUMOR sample - string
--bed_file=BED (Browser Extensible Data) lines have four required fields included chr, start, end and gene annotation. - string
--workDir=working directory - character
--help - print this text
Example:
Rscript cn.mops.R --Tumor=TumorSample.bam --Normal=NormalSample.bam --TumorSampleID=TumorSampleID --bed_file=bedFile --workDir=./ \n\n") #--outputDir=./
q(save="no")
}
#
####2.2.3 Parse arguments (we expect the form --arg=value)
parseArgs <- function(x) strsplit(sub("^--", "", x), "=")
argsDF <- as.data.frame(do.call("rbind", parseArgs(args)))
argsL <- as.list(as.character(argsDF$V2))
names(argsL) <- argsDF$V1
args<-argsL
#
## Arg1 default
if(is.null(args$Tumor)) {
stop("Tumor sample bamFile is missing")
}else{
Tumor=args$Tumor
}
#
## Arg2 default
if(is.null(args$Normal)) {
stop("Normal sample bamFileis missing")
}else{
Normal=args$Normal
}
#
## Arg3 default
if(is.null(args$TumorSampleID)) {
stop("TumorSampleID missing")
}else{
TumorSampleID=args$TumorSampleID
}
#
## Arg4 default
if(is.null(args$bed_file)) {
stop("bed_file is missing")
}else{
bed_file=args$bed_file
}
#
## Arg5 default
if(is.null(args$workDir)) {
stop("workDir is missing")
}else{
workDir=args$workDir
}
#
#3 Run cn.mops
# Tumor <- c("Illumina_pt2_B1700.chr20_X.sorted.deduped.bam")
# Normal <- c("Illumina_pt2_B17NC.chr20_X.sorted.deduped.bam")
# workDir <- "/home/zhangjiyang/shiJzhiP/shijianzhiP2/scripts"
# outputDir <- "/home/zhangjiyang/shiJzhiP/shijianzhiP2/scripts"
# bed_file <- "Illumina_pt2_exonanno_exonfrom1_chr20_X.bed"
#
##3.1 BAM files and bed file as input.
BAMFiles <- c(Tumor,Normal)
segments <- read.table(paste0(workDir,"/", bed_file),sep="\t",as.is=TRUE)
#
##3.2 Get read counts from BAM.
gr <- GRanges(segments[,1],IRanges(segments[,2],segments[,3]))
#
##3.3 The result object
sample <- getSegmentReadCountsFromBAM(BAMFiles,GR=gr,mode="paired")
resRef <- referencecn.mops(cases=sample[,1],controls=sample[,2],
classes=c("CN0", "CN1", "CN2", "CN3", "CN4", "CN5", "CN6",
"CN7","CN8","CN16","CN32","CN64","CN128"),
I = c(0.025, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 8, 16, 32, 64),
segAlgorithm="DNAcopy")
result<- calcIntegerCopyNumbers(resRef)
CNVs <- as.data.frame(cnvs(result))
colnames(segments) <- c("chr","start","end","anno")
colnames(CNVs)[colnames(CNVs)=="seqnames"] <- c("chr")
bed.anno <- segments
bed.anno$start_idx <- paste(bed.anno$chr,bed.anno$start,sep="_")
bed.anno$end_idx <- paste(bed.anno$chr,bed.anno$end,sep="_")
CNV_number <- nrow(CNVs)
Res <- data.frame()
for(i in 1:CNV_number) {
CNVs.start.idx <- paste(CNVs[i,]$chr,CNVs[i,]$start,sep="_")
CNVs.end.idx <- paste(CNVs[i,]$chr,CNVs[i,]$end,sep="_")
exon_start <- rownames(bed.anno[bed.anno$start_idx%in%CNVs.start.idx,])
exon_end <- rownames(bed.anno[bed.anno$end_idx%in%CNVs.end.idx,])
res <- CNVs[i,]
res$gene <- unlist(strsplit(bed.anno[exon_start,]$anno,split = "_"))[1]
res$exon_start <- unlist(strsplit(bed.anno[exon_start,]$anno,split = "_"))[2]
res$exon_end <- unlist(strsplit(bed.anno[exon_end,]$anno,split = "_"))[2]
Res <- rbind(Res,res)
}
Res <- data.frame(sampleName=Res$sampleName,chr=Res$chr,
start=Res$start,end=Res$end,gene=Res$gene,
exon_start=Res$exon_start,exon_end=Res$exon_end,
CN=Res$CN)
#
##3.4 Output
write.table(Res,paste0(TumorSampleID,"cn.mops.res.txt"),sep="\t",
col.names=T,row.names=F,quote=F)




+ 28
- 0
Docker/cn_mops ファイルの表示

@@ -0,0 +1,28 @@
#!/bin/bash

# Wrapper to easily run an R script at the command line, with arguments,
# like you're used to with Python/Perl/Ruby/Bash/anything else remotely sane.
#
# Usage:
# $(echo $0) -p <program_name> <args>

set -eu -o pipefail

export LC_ALL=en_US.UTF-8

# Find original directory of bash script, resolving symlinks
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in/246128#246128
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
BINDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo "Binary directory: ${BINDIR}"

if [ -f "$BINDIR/cn.mops.R" ];then
Rscript "$BINDIR/cn.mops.R" "$@"
else
echo "No such r script: $BINDIR/cn.mops.R"
fi

+ 2
- 3
inputs ファイルの表示

@@ -1,9 +1,8 @@
{
"{{ project_name }}.TumorBam": "{{ TumorBam }}",
"{{ project_name }}.TumorSampleID": "{{ TumorSampleID }}",
"{{ project_name }}.docker": "{{ docker }}",
"{{ project_name }}.cluster_config": "{{ cluster_config }}",
"{{ project_name }}.workDir": "{{ workDir }}",
"{{ project_name }}.docker": "registry-vpc.cn-shanghai.aliyuncs.com/pgx-docker-registry/cn_mops:v0.1.0",
"{{ project_name }}.cluster_config": "OnDemand bcs.a2.3xlarge img-ubuntu-vpc",
"{{ project_name }}.NormalBam": "{{ NormalBam }}",
"{{ project_name }}.disk_size": "{{ disk_size }}",
"{{ project_name }}.bed_file": "{{ bed_file }}"

+ 2
- 3
tasks/cn_mops.wdl ファイルの表示

@@ -3,13 +3,12 @@ task CNV {
String NormalBam
String TumorSampleID
String bed_file
String workDir
String docker
String disk_size
String cluster_config
command <<<
Rscript cn.mops.R --Tumor=${TumorBam} --Normal=${NormalBam} --TumorID==${TumorSampleID} --bed_file=${bed_file} --workDir=${workDir}
cn_mops --Tumor=${TumorBam} --Normal=${NormalBam} --TumorID==${TumorSampleID} --bed_file=${bed_file} --workDir=.
>>>

runtime {
@@ -19,6 +18,6 @@ task CNV {
dataDisk: "cloud_ssd " + disk_size + " /cromwell_root/"
}
output {
File sorted_bam = "${TumorSampleID}.cn.mops.res.txt"
File cn_mops = "${TumorSampleID}.cn.mops.res.txt"
}
}

読み込み中…
キャンセル
保存