Skip to content

Commit

Permalink
Adding option to have different x.cuts in volcano
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagochst committed Nov 30, 2016
1 parent f0d8311 commit e9a2390
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 26 deletions.
20 changes: 14 additions & 6 deletions R/TCGAPrepare.R
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,20 @@ get.GRCh.bioMart <- function(genome="hg19") {
"ensembl_gene_id",
"external_gene_name")
}
message(paste0("Downloading genome information. Using: ",
listDatasets(ensembl)[listDatasets(ensembl)$dataset=="hsapiens_gene_ensembl",]$description))
chrom <- c(1:22, "X", "Y")
gene.location <- getBM(attributes = attributes,
filters = c("chromosome_name"),
values = list(chrom), mart = ensembl)
description <- listDatasets(ensembl)[listDatasets(ensembl)$dataset=="hsapiens_gene_ensembl",]$description
message(paste0("Downloading genome information. Using: ", description))

filename <- paste0(gsub("[[:punct:]]| ", "_",description),".rda")
if(!file.exists(filename)) {
chrom <- c(1:22, "X", "Y")
gene.location <- getBM(attributes = attributes,
filters = c("chromosome_name"),
values = list(chrom), mart = ensembl)
save(gene.location, file = filename)
} else {
message("Loading")
gene.location <- get(load(filename))
}

return(gene.location)
}
Expand Down
7 changes: 5 additions & 2 deletions R/TCGAvisualize.R
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ unlistlabels <- function(lab) {
#' @importFrom grid gpar grid.rect
#' @importFrom data.table dcast setDT setDF :=
#' @examples
#' mut <- GDCquery_Maf(tumor = "ACC", pipelines = "muse")
#' mut <- GDCquery_Maf(tumor = "ACC", pipelines = "mutect")
#' TCGAvisualize_oncoprint(mut = mut, genes = mut$Hugo_Symbol[1:10], rm.empty.columns = TRUE)
#' TCGAvisualize_oncoprint(mut = mut, genes = mut$Hugo_Symbol[1:10],
#' filename = "onco.pdf",
Expand Down Expand Up @@ -1050,8 +1050,11 @@ TCGAvisualize_oncoprint <- function (mut,

if(missing(annotation)) annotation <- NULL
if(!is.null(annotation)){
if(!"bcr_patient_barcode" %in% colnames(annotation))
stop("bcr_patient_barcode column should be in the annotation")
idx <- match(substr(colnames(mat),1,12),annotation$bcr_patient_barcode)

if(all(is.na(idx)))
stop(" We couldn't match the columns names with the bcr_patient_barcode column in the annotation object")
annotation <- annotation[idx,]

annotation$bcr_patient_barcode <- NULL
Expand Down
30 changes: 22 additions & 8 deletions R/methylation.R
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,9 @@ calculate.pvalues <- function(data,
#' Observation: This function automatically is called by TCGAanalyse_DMR
#' @param x x-axis data
#' @param y y-axis data
#' @param y.cut p-values threshold. Default: 0.01
#' @param x.cut x-axis threshold. Default: 0.0
#' @param y.cut p-values threshold.
#' @param x.cut x-axis threshold. Default: 0.0 If you give only one number (e.g. 0.2) the cut-offs will be
#' -0.2 and 0.2. Or you can give diffenrent cutt-ofs as a vector (e.g. c(-0.3,0.4))
#' @param filename Filename. Default: volcano.pdf, volcano.svg, volcano.png
#' @param legend Legend title
#' @param color vector of colors to be used in graph
Expand Down Expand Up @@ -696,6 +697,9 @@ calculate.pvalues <- function(data,
#' TCGAVisualize_volcano(x,y,filename = NULL,y.cut = 10000000,x.cut=0.8,
#' names = as.character(1:length(x)), legend = "Status",
#' names.fill = TRUE, highlight = c("1","2"),show="both")
#' TCGAVisualize_volcano(x,y,filename = NULL,y.cut = 10000000,x.cut=c(-0.3,0.8),
#' names = as.character(1:length(x)), legend = "Status",
#' names.fill = TRUE, highlight = c("1","2"),show="both")
#' while (!(is.null(dev.list()["RStudioGD"]))){dev.off()}
TCGAVisualize_volcano <- function(x,y,
filename = "volcano.pdf",
Expand Down Expand Up @@ -738,20 +742,30 @@ TCGAVisualize_volcano <- function(x,y,
# get significant data
sig <- y < y.cut
sig[is.na(sig)] <- FALSE

# If x.cut
if(length(x.cut) == 1) {
x.cut.min <- -x.cut
x.cut.max <- x.cut
}
if(length(x.cut) == 2) {
x.cut.min <- x.cut[1]
x.cut.max <- x.cut[2]
}

# hypermethylated/up regulated samples compared to old state
up <- x > x.cut
up <- x > x.cut.max
up[is.na(up)] <- FALSE
if (any(up & sig)) threshold[up & sig] <- "2"

# hypomethylated/ down regulated samples compared to old state
down <- x < (-x.cut)
down <- x < x.cut.min
down[is.na(down)] <- FALSE
if (any(down & sig)) threshold[down & sig] <- "3"

if(!is.null(highlight)){
idx <- which(names %in% highlight)
if(length(idx) >0 ){
print(idx)
threshold[which(names %in% highlight)] <- "4"
color <- c(color,highlight.color)
names(color) <- as.character(1:4)
Expand All @@ -774,9 +788,9 @@ TCGAVisualize_volcano <- function(x,y,
environment = .e) +
geom_point() +
ggtitle(title) + ylab(ylab) + xlab(xlab) +
geom_vline(aes(xintercept = -x.cut),
colour = "black",linetype = "dashed") +
geom_vline(aes(xintercept = x.cut),
geom_vline(aes(xintercept = x.cut.min),
colour = "black", linetype = "dashed") +
geom_vline(aes(xintercept = x.cut.max),
colour = "black", linetype = "dashed") +
geom_hline(aes(yintercept = -1 * log10(y.cut)),
colour = "black", linetype = "dashed") +
Expand Down
16 changes: 10 additions & 6 deletions man/TCGAVisualize_volcano.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/TCGAvisualize_meanMethylation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/TCGAvisualize_oncoprint.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e9a2390

Please sign in to comment.