From ae62fe51ca5be284b0c460501c3de47eb32be740 Mon Sep 17 00:00:00 2001 From: leefall Date: Mon, 25 Nov 2019 22:12:10 +0900 Subject: [PATCH 1/4] Update VisCap.R I add code for bed interval file including chomosome number with prefix "Chr". Current version does not work with interval files which is composed of "chr" prefix chromosome such as example interval file provided in git-hub wiki page ( https://github.com/pughlab/VisCap/wiki/Interval-file ). --- VisCap.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VisCap.R b/VisCap.R index e83275f..09e3d5e 100644 --- a/VisCap.R +++ b/VisCap.R @@ -136,7 +136,7 @@ heatmap_by_chrom <- function(mat, analysis_name, ylimits, out_dir) { pdf(file=paste(out_dir, "/", analysis_name, ".pdf", sep="")) #Per-chromosome plots - chroms = c("all", 1:22,"X","Y", "MT", "M") + if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c("all",paste("chr",1:22,sep=""),"X","Y", "MT", "M")}else{chroms = c("all", 1:22,"X","Y", "MT", "M")} for(chr in chroms){ if(chr == "all") { main_title <- "All Chromosomes" @@ -255,7 +255,7 @@ call_cnvs <- function(nmat, ylimits, interval_lookup, threshold.min_exons, iqr_m for(id in colnames(nmat_cnvs)) { segs <- c() segs.header <- c("Sample", "CNV", "Genome_start_interval", "Genome_end_interval", "Start_interval","End_interval", "Interval_count", "Min_log2ratio", "Median_log2ratio", "Max_log2ratio", "Loss_threshold", "Gain_threshold", "Batch_size") - chroms = c(1:22,"X","Y", "MT", "M") + if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c(paste("chr",1:22,sep=""),"X","Y", "MT", "M")}else{chroms = c(1:22,"X","Y", "MT", "M")} for(chr in chroms){ matches <- grep(paste("^",chr,":",sep=""), rownames(nmat)) if(length(matches) > 1) { @@ -347,7 +347,7 @@ exon_plot_per_sample <- function(nmat, ylimits, interval_lookup, cnv_bplot_and_c #Plot all intervals, then plot by chromosome pdf(file=paste(out_dir, "/", name, ".plot.pdf", sep="")) - chroms <- c(".*", 1:22, "X", "Y") + if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c(".*",paste("chr",1:22,sep=""),"X","Y")}else{chroms = c(".*", 1:22,"X","Y")} for(chr in chroms) { #Grep rownames with genome coordinates for desired chromosome, support chr1: and 1: formats matches <- grep(paste("(^chr", chr, "|^", chr, "):", sep=""), rownames(nmat)) @@ -566,7 +566,7 @@ mat.all[which(mat.all==0)]=0.00001 interval_lookup <- load_interval_names(interval_list_dir, interval_file_pattern) # Sort matrix by genome coordinates found in rownames -chroms <- c(1:22,"X","Y", "MT", "M") +chroms <- c(paste("chr",1:22,sep=""),"X","Y", "MT", "M")}else{chroms <- c(1:22,"X","Y", "MT", "M")} chroms <- factor(chroms, levels=chroms, labels=chroms, ordered=TRUE) coords <- matrix(unlist(strsplit(rownames(mat.all), ":|-")), ncol=3, byrow=TRUE, dimnames=list(rownames(mat.all))) coords <- coords[order(match(coords[,1], chroms), as.numeric(coords[,2]), as.numeric(coords[,3])),] From 3da8d255b883308217df38b2707a8127374f81da Mon Sep 17 00:00:00 2001 From: leefall Date: Mon, 25 Nov 2019 22:17:47 +0900 Subject: [PATCH 2/4] Update VisCap.R I add code for bed interval file including chomosome number with prefix "Chr". Current version does not work with interval files which is composed of "chr" prefix chromosome such as example interval file provided in git-hub wiki page ( https://github.com/pughlab/VisCap/wiki/Interval-file ). --- VisCap.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VisCap.R b/VisCap.R index 09e3d5e..e26fc4e 100644 --- a/VisCap.R +++ b/VisCap.R @@ -136,7 +136,7 @@ heatmap_by_chrom <- function(mat, analysis_name, ylimits, out_dir) { pdf(file=paste(out_dir, "/", analysis_name, ".pdf", sep="")) #Per-chromosome plots - if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c("all",paste("chr",1:22,sep=""),"X","Y", "MT", "M")}else{chroms = c("all", 1:22,"X","Y", "MT", "M")} + if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c("all",paste("chr",1:22,sep=""),"chrX","chrY", "chrMT", "chrM")}else{chroms = c("all", 1:22,"X","Y", "MT", "M")} for(chr in chroms){ if(chr == "all") { main_title <- "All Chromosomes" @@ -255,7 +255,7 @@ call_cnvs <- function(nmat, ylimits, interval_lookup, threshold.min_exons, iqr_m for(id in colnames(nmat_cnvs)) { segs <- c() segs.header <- c("Sample", "CNV", "Genome_start_interval", "Genome_end_interval", "Start_interval","End_interval", "Interval_count", "Min_log2ratio", "Median_log2ratio", "Max_log2ratio", "Loss_threshold", "Gain_threshold", "Batch_size") - if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c(paste("chr",1:22,sep=""),"X","Y", "MT", "M")}else{chroms = c(1:22,"X","Y", "MT", "M")} + if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c(paste("chr",1:22,sep=""),"chrX","chrY", "chrMT", "chrM")}else{chroms = c(1:22,"X","Y", "MT", "M")} for(chr in chroms){ matches <- grep(paste("^",chr,":",sep=""), rownames(nmat)) if(length(matches) > 1) { @@ -347,7 +347,7 @@ exon_plot_per_sample <- function(nmat, ylimits, interval_lookup, cnv_bplot_and_c #Plot all intervals, then plot by chromosome pdf(file=paste(out_dir, "/", name, ".plot.pdf", sep="")) - if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c(".*",paste("chr",1:22,sep=""),"X","Y")}else{chroms = c(".*", 1:22,"X","Y")} + if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c(".*",paste("chr",1:22,sep=""),"chrX","chrY")}else{chroms = c(".*", 1:22,"X","Y")} for(chr in chroms) { #Grep rownames with genome coordinates for desired chromosome, support chr1: and 1: formats matches <- grep(paste("(^chr", chr, "|^", chr, "):", sep=""), rownames(nmat)) @@ -566,7 +566,7 @@ mat.all[which(mat.all==0)]=0.00001 interval_lookup <- load_interval_names(interval_list_dir, interval_file_pattern) # Sort matrix by genome coordinates found in rownames -chroms <- c(paste("chr",1:22,sep=""),"X","Y", "MT", "M")}else{chroms <- c(1:22,"X","Y", "MT", "M")} +chroms <- c(paste("chr",1:22,sep=""),"chrX","chrY", "chrMT", "chrM")}else{chroms <- c(1:22,"X","Y", "MT", "M")} chroms <- factor(chroms, levels=chroms, labels=chroms, ordered=TRUE) coords <- matrix(unlist(strsplit(rownames(mat.all), ":|-")), ncol=3, byrow=TRUE, dimnames=list(rownames(mat.all))) coords <- coords[order(match(coords[,1], chroms), as.numeric(coords[,2]), as.numeric(coords[,3])),] From 6216c6e528fa8f189e7ff940857faacd2b9e7a70 Mon Sep 17 00:00:00 2001 From: leefall Date: Fri, 13 Dec 2019 16:38:28 +0900 Subject: [PATCH 3/4] Update VisCap.R Fit the 569 lines after change request --- VisCap.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VisCap.R b/VisCap.R index e26fc4e..5d3ac36 100644 --- a/VisCap.R +++ b/VisCap.R @@ -566,7 +566,8 @@ mat.all[which(mat.all==0)]=0.00001 interval_lookup <- load_interval_names(interval_list_dir, interval_file_pattern) # Sort matrix by genome coordinates found in rownames -chroms <- c(paste("chr",1:22,sep=""),"chrX","chrY", "chrMT", "chrM")}else{chroms <- c(1:22,"X","Y", "MT", "M")} + +if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c(paste("chr",1:22,sep=""),"chrX","chrY", "chrMT", "chrM")}else{chroms <- c(1:22,"X","Y", "MT", "M")} chroms <- factor(chroms, levels=chroms, labels=chroms, ordered=TRUE) coords <- matrix(unlist(strsplit(rownames(mat.all), ":|-")), ncol=3, byrow=TRUE, dimnames=list(rownames(mat.all))) coords <- coords[order(match(coords[,1], chroms), as.numeric(coords[,2]), as.numeric(coords[,3])),] From c6f1f34dfcfc50fbdd883aebb44267c426f31523 Mon Sep 17 00:00:00 2001 From: leefall Date: Fri, 13 Dec 2019 16:39:31 +0900 Subject: [PATCH 4/4] Update VisCap.R fix line 569 after change request about if statement --- VisCap.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/VisCap.R b/VisCap.R index 5d3ac36..bf36a08 100644 --- a/VisCap.R +++ b/VisCap.R @@ -565,8 +565,7 @@ mat.all[which(mat.all==0)]=0.00001 # Read interval name files interval_lookup <- load_interval_names(interval_list_dir, interval_file_pattern) -# Sort matrix by genome coordinates found in rownames - +# Sort matrix by genome coordinates found in rownames if(length(interval_lookup$chr[grep("chr",interval_lookup$chr)])!=0){chroms <- c(paste("chr",1:22,sep=""),"chrX","chrY", "chrMT", "chrM")}else{chroms <- c(1:22,"X","Y", "MT", "M")} chroms <- factor(chroms, levels=chroms, labels=chroms, ordered=TRUE) coords <- matrix(unlist(strsplit(rownames(mat.all), ":|-")), ncol=3, byrow=TRUE, dimnames=list(rownames(mat.all)))