Mercurial > repos > bornea > saint_bubblebeam
changeset 22:503f1c1bac0c draft
Deleted selected files
author | bornea |
---|---|
date | Tue, 12 Jan 2016 16:22:25 -0500 |
parents | 7ce59d092bae |
children | cb7223752458 |
files | Bubblebeam_For_SAINT_wrapper.py Bubblebeam_For_SAINT_wrapper.xml bubbles_v9_NSAF_natural_log.R tool_dependencies.xml |
diffstat | 4 files changed, 0 insertions(+), 444 deletions(-) [+] |
line wrap: on
line diff
--- a/Bubblebeam_For_SAINT_wrapper.py Fri Nov 20 12:04:24 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -import os -import sys -import time - - -list_file = sys.argv[1] -prey_file = sys.argv[2] -crapome = sys.argv[3] -color = sys.argv[4] -label = sys.argv[5] -cutoff = sys.argv[6] -mq_sc = sys.argv[7] -inc_file = sys.argv[8] -exc_file = sys.argv[9] -output_file_name = sys.argv[10] -bub_zoom_NSAF = sys.argv[11] -bub_zoom_SAINT =sys.argv[12] -bub_SAINT = sys.argv[13] -bub_NSAF = sys.argv[14] -ins_path =sys.argv[15] - -if crapome == "None": - crapome = "FALSE" - - -if label == "false": - label = "FALSE" -elif label == "true": - label = "TRUE" - -cmd = r"Rscript "+ str(ins_path) + r"/bubbles_v9_NSAF_natural_log.R " + str(list_file) + r" " + str(prey_file) + r" " + str(crapome) + r" " + str(color) + r" " + str(label) + r" " + str(cutoff) + r" " + str(mq_sc) + r" " + str(inc_file) + r" " + str(exc_file) -os.system(cmd) -time.sleep(3) - -open('./output.txt') -os.rename('output.txt', str(output_file_name)) - -open('./bubble_zoom_NSAF.png') -os.rename('bubble_zoom_NSAF.png', str(bub_zoom_NSAF)) - -open('./bubble_zoom_SAINT.png') -os.rename('bubble_zoom_SAINT.png', str(bub_zoom_SAINT)) - -open('./bubble_SAINT.png') -os.rename('bubble_SAINT.png', str(bub_SAINT)) - -open('./bubble_NSAF.png') -os.rename('bubble_NSAF.png', str(bub_NSAF)) -
--- a/Bubblebeam_For_SAINT_wrapper.xml Fri Nov 20 12:04:24 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -<tool id="Bubblebeam_For_SAINT" name="Bubblebeam For SAINT"> - <description></description> - <command interpreter="python">Bubblebeam_For_SAINT_wrapper.py $list_file $prey_file $crapome $color $label $cutoff $type $inc_file $exc_file $outfile $NSAF_zoom $SAINT_zoom $SAINT $NSAF \$INSTALL_RUN_PATH/</command> - <requirements> - <requirement type="set_environment">INSTALL_RUN_PATH</requirement> - <requirement type="package" version="3.2.1">package_r_3_2_1</requirement> - </requirements> - <inputs> - <param type="select" name="type" label="MaxQuant or Scaffold"> - <option value="MQ">MaxQuant</option> - <option value="SC">Scaffold</option> - </param> - <param format="txt" name="list_file" type="data" label="List File"/> - <param format="txt" name="prey_file" type="data" label="Prey File"/> - <param format="txt" name="crapome" type="data" label="Crapome File" optional="true"/> - <param name="color" type="select" label="Color"> - <option value="crapome">Crapome</option> - <option value="red">Red</option> - <option value="blue">Blue</option> - </param> - <param type="boolean" name="label" checked="true" label="Use Labels"/> - <param type="float" name="cutoff" label="SAINT Score Cutoff" help="Select a value between 0 and 1 written like 0.8." value="0.8"/> - <param format="txt" name="inc_file" type="data" label="List of Uniprot IDs to Include" optional="true"/> - <param format="txt" name="exc_file" type="data" label="List of Uniprot IDs to Include" optional="true"/> - </inputs> - <outputs> - <data format="txt" name="outfile" label="Outfile"/> - <data format="png" name="NSAF_zoom" label="Zoom NSAF" /> - <data format="png" name="SAINT_zoom" label="Zoom SAINT" /> - <data format="png" name="NSAF" label="NSAF" /> - <data format="png" name="SAINT" label="SAINT" /> - </outputs> - <stdio> - <regex match="error" - source="stdout" - level="fatal" - description="Unknown error"/> - </stdio> - - <tests> - <test> - <param name="input" value="fa_gc_content_input.fa"/> - <output name="out_file1" file="fa_gc_content_output.txt"/> - </test> - </tests> - <help> -Post-processing: -Once SAINTexpress has been run, APOSTL is able to read the resulting "list.txt" file. Fromhere APOSTL does a number of things: - -APOSTL calculates NSAF values for each prey based on the average spectra observed for each bait - -OPTIONAL: APOSTL calculates the probability of a specific interaction based on prey revalence in the CRAPome - -Bubble graphs are generated for each bait where: - -- x axis is the natural log of the NSAF values - -- y axis is the observed log2 fold change (as compared to control) - -- bubble radius is proportional to the average observed spectra - -OPTIONAL: bubble color corresponds to the CRAPome probability of a specific interaction in which an 80% cutoff is applied where prey with less than 80% are colored tan - -APOSTL queries ConsensusPathDB for protein-protein interactions within your data and then formats the resulting network for simple cytoscape import using the "import network from file" option. - -INPUTS: - -List File: - -- SAINTexpress generated "list.txt" file - -Prey File: - -- SAINT pre-processing generated "prey.txt" file used to run SAINTexpress - -Crapome File: - -- raw output from Crapome Workflow 1 query (http://www.crapome.org) - -Color: - -- Specify the color of the bubbles within the graph. - -- If "crapome" is chosen and 'crapome' file is specified, bubbles will be color based on crapome specificity - -Use labels: - -- Adds gene name labels to bubbles within the "zoomed in" graphs -SAINT Score Cutoff: - -- Choose Saintscore cutoff (between 0-1) to be used for filtering the "zoomed in" graphs (default = 0.8) - -- Also used for filtering during the generation of the cytoscape network - -Species: - -- Human, mouse, or yeast - -Interaction Confidence: - -- Interaction confidence value (0-1) used to filter the interactions with the ConsensusPathDB database - -- Suggestions: - -* low: 0 - -* medium: 0.5 - -* high: 0.7 - -* very high: 0.9 - -OUTPUTS: - -Bubble Graphs: - -- Unfiltered Data: - -* NSAF v. Log2(FoldChange) - -* SAINTscore v. Log2(FoldChange) - -- Filtered by SAINT Score - -* NSAF v. Log2(FoldChange) - -* SAINTscore v. Log2(FoldChange) - -Output.txt -- SAINTexpress "list.txt" output with additional columns that were used during the analysis - </help> -</tool>
--- a/bubbles_v9_NSAF_natural_log.R Fri Nov 20 12:04:24 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,252 +0,0 @@ -rm(list=ls()) -################################################################################################### -# R-code: Multi-bubble graph generation from SAINTexpress output -# Author: Brent Kuenzi -################################################################################################### -ins_check_run <- function(){ - if ('dplyr' %in% rownames(installed.packages())){} - else { - install.packages('dplyr', repos='http://cran.us.r-project.org') - } - if ('tidyr' %in% rownames(installed.packages())){} - else { - install.packages('tidyr', repos='http://cran.us.r-project.org') - } - if ('ggplot2' %in% rownames(installed.packages())){} - else { - install.packages('ggplot2', repos='http://cran.us.r-project.org') - } -} -ins_check_run() -library(dplyr); library(tidyr); library(ggplot2) -################################################################################################### -### Run program ### - -## REQUIRED INPUT ## -# 1) listfile: SAINTexpress generated "list.txt" file -# 2) preyfile: SAINT pre-processing generated "prey.txt" file used to run SAINTexpress -## OPTIONAL INPUT ## -# 3) crapome: raw output from crapome Workflow 1 query (http://www.crapome.org) -# 4) color: bubble color (default = "red") -# - color= "crapome": color bubbles based on Crapome(%) -# - Also recognizes any color within R's built-in colors() vector -# 5) label: Adds gene name labels to bubbles within the "zoomed in" graphs (default = FALSE) -# 6) cutoff: Saintscore cutoff to be assigned for filtering the "zoomed in" graphs (default = 0.8) -################################################################################################### -main <- function(listfile, preyfile , crapome=FALSE, color="red", label=FALSE, cutoff=0.8, type="SC", inc_file = "None", exc_file = "None" ) { - cutoff_check(cutoff) - listfile <- list_type(listfile, inc_file, exc_file) - if(type == "SC") { - df <- merge_files_sc(listfile, preyfile, crapome) - } - if(type == "MQ") { - df <- merge_files_mq(listfile, preyfile, crapome) - } - bubble_NSAF(df,color) - bubble_SAINT(df,color) - bubble_zoom_SAINT(df, color, label, cutoff) - bubble_zoom_NSAF(df, color, label, cutoff) - write.table(df,"output.txt",sep="\t",quote=FALSE, row.names=FALSE) -} - -list_type <- function(df, inc_file, exc_file) { - Saint <- read.delim(df, stringsAsFactors=FALSE) - if (inc_file != "None") { - if (exc_file == "None"){ - inc_prots <- read.delim(inc_file, sep='\t', header=FALSE, stringsAsFactors=FALSE) - print(inc_prots[,1]) - print(Saint$Prey) - filtered_df = subset(Saint, Saint$Prey == inc_prots[,1]) - } - else { - inc_prots <- read.delim(inc_file, sep='\t', header=FALSE, stringsAsFactors=FALSE) - exc_prots <- read.delim(exc_file, sep='\t', header=FALSE, stringsAsFactors=FALSE) - filtered_df = subset(Saint, Saint$Prey == inc_prots[,1]) - filtered_df = subset(filtered_df, filtered_df$Prey != exc_prots[,1]) - } - } - else if (exc_file != "None") { - exc_prots <- read.delim(exc_file, sep='\t', header=FALSE, stringsAsFactors=FALSE) - filtered_df = subset(Saint, Saint$Prey != exc_prots[,1]) - } - else { - filtered_df = Saint - } - return(filtered_df) - -} -################################################################################################### -# Merge input files and caculate Crapome(%) and NSAF for each protein for each bait -################################################################################################### -merge_files_mq <- function(SAINT, prey_DF, crapome=FALSE) { - #SAINT <- read.table(SAINT_DF, sep='\t', header=TRUE) - prey <- read.table(prey_DF, sep='\t', header=FALSE); colnames(prey) <- c("Prey", "Length", "PreyGene") - DF <- merge(SAINT,prey) - DF$SpecSum <- log2(DF$SpecSum) - - if(crapome!=FALSE) { - crapome <- read.table(crapome, sep='\t', header=TRUE) - colnames(crapome) <- c("Prey", "Symbol", "Num.of.Exp", "Ave.SC", "Max.SC") - DF1 <- merge(DF, crapome); as.character(DF1$Num.of.Exp); DF1$Symbol <- NULL; - DF1$Ave.SC <- NULL; DF1$Max.SC <- NULL #remove unnecessary columns - DF1$Num.of.Exp <- sub("^$", "0 / 1", DF1$Num.of.Exp ) #replace blank values with 0 / 1 - DF <- DF1 %>% separate(Num.of.Exp, c("NumExp", "TotalExp"), " / ") #split into 2 columns - DF$CrapomePCT <- 100 - (as.integer(DF$NumExp) / as.integer(DF$TotalExp) * 100) #calculate crapome % - } - DF$SAF <- DF$AvgSpec / DF$Length - DF2 = DF %>% group_by(Bait) %>% mutate(NSAF = SAF/sum(SAF)) - DF$NSAF = DF2$NSAF - return(DF) -} - -merge_files_sc <- function(SAINT, prey_DF, crapome=FALSE) { - #SAINT <- read.table(SAINT_DF, sep='\t', header=TRUE) - prey <- read.table(prey_DF, sep='\t', header=FALSE); colnames(prey) <- c("Prey", "Length", "PreyGene") - DF <- merge(SAINT,prey) - - if(crapome!=FALSE) { - crapome <- read.table(crapome, sep='\t', header=TRUE) - colnames(crapome) <- c("Prey", "Symbol", "Num.of.Exp", "Ave.SC", "Max.SC") - DF1 <- merge(DF, crapome); as.character(DF1$Num.of.Exp); DF1$Symbol <- NULL; - DF1$Ave.SC <- NULL; DF1$Max.SC <- NULL #remove unnecessary columns - DF1$Num.of.Exp <- sub("^$", "0 / 1", DF1$Num.of.Exp ) #replace blank values with 0 / 1 - DF <- DF1 %>% separate(Num.of.Exp, c("NumExp", "TotalExp"), " / ") #split into 2 columns - DF$CrapomePCT <- 100 - (as.integer(DF$NumExp) / as.integer(DF$TotalExp) * 100) #calculate crapome % - } - DF$SAF <- DF$AvgSpec / DF$Length - DF2 = DF %>% group_by(Bait) %>% mutate(NSAF = SAF/sum(SAF)) - DF$NSAF = DF2$NSAF - return(DF) -} -################################################################################################### -# Plot all proteins for each bait by x=ln(NSAF), y=Log2(FoldChange) -################################################################################################### -bubble_NSAF <- function(data, color) { - if(color=="crapome") { - a <- subset(data, CrapomePCT <80, select = c(NSAF,SpecSum, CrapomePCT, FoldChange, SaintScore, Bait)) - b <- subset(data, CrapomePCT>=80, select = c(NSAF,SpecSum, CrapomePCT, FoldChange, SaintScore, Bait)) - p <- qplot(x=log(NSAF), y=log2(FoldChange), data=a, colour=I("tan"),size=SpecSum) + scale_size(range=c(1,10)) + - geom_point(aes(x=log(NSAF),y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=a) - if(length(levels(a$Bait) > 1)) {p <- p + facet_wrap(~Bait, scales="free_y")} # multiple graphs if multiple baits - p <- p + geom_point(aes(x=log(NSAF),y=log2(FoldChange), size=SpecSum, color=CrapomePCT), data=b) + - scale_colour_gradient(limits=c(80, 100), low="tan", high="red") + - labs(colour="CRAPome Probability \nof Specific Interaction (%)", x="ln(NSAF)") + - geom_point(aes(x=log(NSAF),y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=b) - return(ggsave(p, width=8,height=4,filename = "bubble_NSAF.png")) - } - if(color != "crapome") { - p <- qplot(x=log(NSAF), y=log2(FoldChange), data=data, colour=I(color),size=SpecSum) + scale_size(range=c(1,10)) + - geom_point(aes(x=log(NSAF),y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=data) + # add bubble outlines - labs(x="ln(NSAF)") - if(length(levels(data$Bait) > 1)) {p <- p + facet_wrap(~Bait, scales="free_y")} - return(ggsave(p, width=8,height=4,filename = "bubble_NSAF.png")) - } - } -################################################################################################### -# Plot all proteins for each bait by x=Saintscore, y=Log2(FoldChange) -################################################################################################### -bubble_SAINT <- function(data, color) { - if(color=="crapome") { - a <- subset(data, CrapomePCT <80, select = c(NSAF,SpecSum, CrapomePCT, FoldChange, SaintScore, Bait)) #filter on CRAPome - b <- subset(data, CrapomePCT >=80, select = c(NSAF,SpecSum, CrapomePCT, FoldChange, SaintScore, Bait)) - p <- qplot(x=SaintScore, y=log2(FoldChange), data=a, colour=I("tan"),size=SpecSum) + - scale_size(range=c(1,10)) + geom_point(aes(x=SaintScore,y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=a) - if(length(levels(a$Bait) > 1)) {p <- p + facet_wrap(~Bait, scales="free_y")} - p <- p + geom_point(aes(x=SaintScore,y=log2(FoldChange), size=SpecSum, color=CrapomePCT), data=b) + - scale_colour_gradient(limits=c(80, 100), low="tan", high="red") + - labs(colour="CRAPome Probability \nof Specific Interaction (%)") + - geom_point(aes(x=SaintScore,y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=b) - return(ggsave(p, width=8,height=4,filename = "bubble_SAINT.png")) - } - if(color != "crapome") { - p <- qplot(x=SaintScore, y=log2(FoldChange), data=data, colour=I(color),size=SpecSum) + - scale_size(range=c(1,10)) + geom_point(aes(x=SaintScore,y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=data) - if(length(levels(data$Bait) > 1)) {p <- p + facet_wrap(~Bait, scales="free_y")} - return(ggsave(p, width=8,height=4,filename = "bubble_SAINT.png")) - } - } -################################################################################################### -# Filter proteins on Saintscore cutoff and plot for each bait x=Saintscore, y=Log2(FoldChange) -################################################################################################### -bubble_zoom_SAINT <- function(data, color, label=FALSE, cutoff=0.8) { - if(color=="crapome") { - a <- subset(data, CrapomePCT <80 & SaintScore>=cutoff, select = c(NSAF,SpecSum, CrapomePCT, FoldChange, SaintScore, Bait, PreyGene)) - b <- subset(data, CrapomePCT >=80 & SaintScore >=cutoff, select = c(NSAF,SpecSum, CrapomePCT, FoldChange, SaintScore, Bait, PreyGene)) - p <- qplot(x=SaintScore, y=log2(FoldChange), data=a, colour=I("tan"),size=SpecSum) + - scale_size(range=c(1,10)) + ggtitle("Filtered on SAINT score")+geom_point(aes(x=SaintScore,y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=a) - if(label==TRUE & length(a$NSAF!=0)) { - p <- p + geom_text(data=a, aes(label=PreyGene, size=10, vjust=0, hjust=0),colour="black") - } - if(length(levels(a$Bait) > 1)) {p <- p + facet_wrap(~Bait, scales="free_y")} - p <- p + geom_point(aes(x=SaintScore,y=log2(FoldChange), size=SpecSum, color=CrapomePCT), data=b) + - scale_colour_gradient(limits=c(80, 100), low="tan", high="red") + - labs(colour="CRAPome Probability \nof Specific Interaction (%)") + - geom_point(aes(x=SaintScore,y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=b) - if(label==TRUE & length(b$NSAF!=0)) { - p <- p + geom_text(data=b, aes(label=PreyGene, size=10, vjust=0, hjust=0),colour="black", show_guide=FALSE) - } - return(ggsave(p, width=8,height=4,filename = "bubble_zoom_SAINT.png")) - } - if(color != "crapome") { - a <- subset(data, SaintScore>=cutoff, select = c(NSAF,SpecSum, FoldChange, SaintScore, Bait, PreyGene)) - p <- qplot(x=SaintScore, y=log2(FoldChange), data=a, colour=I(color),size=SpecSum) + - scale_size(range=c(1,10)) + ggtitle("Filtered on SAINT score") + - geom_point(aes(x=SaintScore,y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=a) - if(label==TRUE & length(a$NSAF!=0)) { - p <- p + geom_text(data=a, aes(label=PreyGene, size=10, vjust=0, hjust=0),colour="black", show_guide=FALSE) - } - if(length(levels(data$Bait) > 1)) {p <- p + facet_wrap(~Bait, scales="free_y")} - return(ggsave(p, width=8,height=4,filename = "bubble_zoom_SAINT.png")) - } -} -################################################################################################### -# Filter proteins on Saintscore cutoff and plot for each bait x=log(NSAF), y=Log2(FoldChange) -################################################################################################### -bubble_zoom_NSAF <- function(data, color, label=FALSE, cutoff=0.8) { - if(color=="crapome") { - a <- subset(data, CrapomePCT <80 & SaintScore>=cutoff, select = c(NSAF,SpecSum, CrapomePCT, FoldChange, SaintScore, Bait, PreyGene)) - b <- subset(data, CrapomePCT >=80 & SaintScore >=cutoff, select = c(NSAF,SpecSum, CrapomePCT, FoldChange, SaintScore, Bait, PreyGene)) - p <- qplot(x=log(NSAF), y=log2(FoldChange), data=a, colour=I("tan"),size=SpecSum) + - scale_size(range=c(1,10)) + ggtitle("Filtered on SAINT score") + - geom_point(aes(x=log(NSAF),y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=a) - if(label==TRUE & length(a$NSAF!=0)) { - p <- p + geom_text(data=a, aes(label=PreyGene, size=10, vjust=0, hjust=0),colour="black") - } - if(length(levels(a$Bait) > 1)) {p <- p + facet_wrap(~Bait, scales="free_y")} - p <- p + geom_point(aes(x=log(NSAF),y=log2(FoldChange), size=SpecSum, color=CrapomePCT), data=b) + - scale_colour_gradient(limits=c(80, 100), low="tan", high="red") + - labs(colour="CRAPome Probability \nof Specific Interaction (%)", x="ln(NSAF)") + - geom_point(aes(x=log(NSAF),y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=b) - if(label==TRUE & length(b$NSAF!=0)) { - p <- p + geom_text(data=b, aes(label=PreyGene, size=10, vjust=0, hjust=0),colour="black", show_guide=FALSE) - } - return(ggsave(p, width=8,height=4,filename = "bubble_zoom_NSAF.png")) - } - if(color != "crapome") { - a <- subset(data, SaintScore>=cutoff, select = c(NSAF,SpecSum, FoldChange, SaintScore, Bait, PreyGene)) - p <- qplot(x=log(NSAF), y=log2(FoldChange), data=a, colour=I(color), size=SpecSum) + - scale_size(range=c(1,10)) + ggtitle("Filtered on SAINT score") + - geom_point(aes(x=log(NSAF),y=log2(FoldChange), size=SpecSum), colour="black", shape=21, data=a) + - labs(x="ln(NSAF)") - if(label==TRUE & length(a$NSAF!=0)) { - p <- p + geom_text(data=a, aes(label=PreyGene, size=10, vjust=0, hjust=0),colour="black", show_guide=FALSE) - } - if(length(levels(data$Bait) > 1)) {p <- p + facet_wrap(~Bait, scales="free_y")} - return(ggsave(p, width=8,height=4,filename = "bubble_zoom_NSAF.png")) - } -} -################################################################################################### -# Check Saintscore cutoff and stop program if not between 0 and 1 -################################################################################################### -cutoff_check <- function(cutoff){ - if( any(cutoff < 0 | cutoff > 1) ) stop('SAINT score cutoff not between 0 and 1. Please correct and try again') -} - - - -args <- commandArgs(trailingOnly = TRUE) -main(args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9]) - -#main("test_list.txt", "preytest.txt", crapome="craptest.txt", color="crapome", label=TRUE) -#main("Crizo_list.txt", "prey_cr.txt", crapome = "crizo_crap.txt", color="crapome", label=TRUE, cutoff=0.7) -#main("test_list.txt", "preytest.txt", crapome=FALSE, color="magenta", label=FALSE, cutoff=1.1) \ No newline at end of file
--- a/tool_dependencies.xml Fri Nov 20 12:04:24 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<tool_dependency> - <install version="1.0"> - <package name="package_r_3_2_1" version="3.2.1"> - <repository toolshed="toolshed.g2.bx.psu.edu" name="package_r_3_2_1" owner="iuc" changeset_revision="fae49a02a848" prior_installation_required="True"/> - </package> - </install> - <set_environment version="1.0"> - <environment_variable name="INSTALL_RUN_PATH" action="set_to">$REPOSITORY_INSTALL_DIR</environment_variable> - </set_environment> -</tool_dependency> \ No newline at end of file