Prefixed all the functions with gsa. in order to distinguish the methods from other possible methods of the same name in the namespace.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4738 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
6f8cd97673
commit
247f33a553
|
|
@ -1,4 +1,4 @@
|
||||||
.getargs.usage <- function(argspec, doc) {
|
.gsa.getargs.usage <- function(argspec, doc) {
|
||||||
cargs = commandArgs();
|
cargs = commandArgs();
|
||||||
|
|
||||||
usage = "Usage:";
|
usage = "Usage:";
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
stop(call. = FALSE);
|
stop(call. = FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
getargs <- function(argspec, doc = NA) {
|
gsa.getargs <- function(argspec, doc = NA) {
|
||||||
argsenv = new.env();
|
argsenv = new.env();
|
||||||
|
|
||||||
for (argname in names(argspec)) {
|
for (argname in names(argspec)) {
|
||||||
|
|
@ -66,7 +66,7 @@ getargs <- function(argspec, doc = NA) {
|
||||||
cargs = commandArgs(TRUE);
|
cargs = commandArgs(TRUE);
|
||||||
|
|
||||||
if (length(cargs) == 0) {
|
if (length(cargs) == 0) {
|
||||||
.getargs.usage(argspec, doc);
|
.gsa.getargs.usage(argspec, doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i in 1:length(cargs)) {
|
for (i in 1:length(cargs)) {
|
||||||
|
|
@ -75,7 +75,7 @@ getargs <- function(argspec, doc = NA) {
|
||||||
value = cargs[i+1];
|
value = cargs[i+1];
|
||||||
|
|
||||||
if (key == "h" | key == "help") {
|
if (key == "h" | key == "help") {
|
||||||
.getargs.usage(argspec, doc);
|
.gsa.getargs.usage(argspec, doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length(grep("^[\\d\\.e\\+\\-]+$", value, perl=TRUE, ignore.case=TRUE)) > 0) {
|
if (length(grep("^[\\d\\.e\\+\\-]+$", value, perl=TRUE, ignore.case=TRUE)) > 0) {
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
plot.venn <-
|
gsa.plot.venn <-
|
||||||
function(a, b, c=0, a_and_b, a_and_c=0, b_and_c=0,
|
function(a, b, c=0, a_and_b, a_and_c=0, b_and_c=0,
|
||||||
col=c("#FF6342", "#63C6DE", "#ADDE63"),
|
col=c("#FF6342", "#63C6DE", "#ADDE63"),
|
||||||
pos=c(0.20, 0.20, 0.80, 0.82),
|
pos=c(0.20, 0.20, 0.80, 0.82),
|
||||||
debug=0
|
debug=0
|
||||||
) {
|
) {
|
||||||
print("This is the gsalib plot.venn function");
|
|
||||||
|
|
||||||
library(png);
|
library(png);
|
||||||
library(graphics);
|
library(graphics);
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.attemptToLoadFile <- function(filename) {
|
.gsa.attemptToLoadFile <- function(filename) {
|
||||||
file = NA;
|
file = NA;
|
||||||
|
|
||||||
if (file.exists(filename) & file.info(filename)$size > 500) {
|
if (file.exists(filename) & file.info(filename)$size > 500) {
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
file;
|
file;
|
||||||
}
|
}
|
||||||
|
|
||||||
read.eval <-
|
gsa.read.eval <-
|
||||||
function(evalRoot) {
|
function(evalRoot) {
|
||||||
fileAlleleCountStats = paste(evalRoot, ".AlleleCountStats.csv", sep="");
|
fileAlleleCountStats = paste(evalRoot, ".AlleleCountStats.csv", sep="");
|
||||||
fileCompOverlap = paste(evalRoot, ".Comp_Overlap.csv", sep="");
|
fileCompOverlap = paste(evalRoot, ".Comp_Overlap.csv", sep="");
|
||||||
|
|
@ -46,20 +46,20 @@ function(evalRoot) {
|
||||||
CallsetFilteredNames = c()
|
CallsetFilteredNames = c()
|
||||||
);
|
);
|
||||||
|
|
||||||
eval$AlleleCountStats = .attemptToLoadFile(fileAlleleCountStats);
|
eval$AlleleCountStats = .gsa.attemptToLoadFile(fileAlleleCountStats);
|
||||||
eval$CompOverlap = .attemptToLoadFile(fileCompOverlap);
|
eval$CompOverlap = .gsa.attemptToLoadFile(fileCompOverlap);
|
||||||
eval$CountVariants = .attemptToLoadFile(fileCountVariants);
|
eval$CountVariants = .gsa.attemptToLoadFile(fileCountVariants);
|
||||||
eval$GenotypeConcordance = .attemptToLoadFile(fileGenotypeConcordance);
|
eval$GenotypeConcordance = .gsa.attemptToLoadFile(fileGenotypeConcordance);
|
||||||
eval$MetricsByAc = .attemptToLoadFile(fileMetricsByAc);
|
eval$MetricsByAc = .gsa.attemptToLoadFile(fileMetricsByAc);
|
||||||
eval$MetricsBySample = .attemptToLoadFile(fileMetricsBySample);
|
eval$MetricsBySample = .gsa.attemptToLoadFile(fileMetricsBySample);
|
||||||
eval$Quality_Metrics_by_allele_count = .attemptToLoadFile(fileQuality_Metrics_by_allele_count);
|
eval$Quality_Metrics_by_allele_count = .gsa.attemptToLoadFile(fileQuality_Metrics_by_allele_count);
|
||||||
eval$QualityScoreHistogram = .attemptToLoadFile(fileQualityScoreHistogram);
|
eval$QualityScoreHistogram = .gsa.attemptToLoadFile(fileQualityScoreHistogram);
|
||||||
eval$SampleStatistics = .attemptToLoadFile(fileSampleStatistics);
|
eval$SampleStatistics = .gsa.attemptToLoadFile(fileSampleStatistics);
|
||||||
eval$SampleSummaryStatistics = .attemptToLoadFile(fileSampleSummaryStatistics);
|
eval$SampleSummaryStatistics = .gsa.attemptToLoadFile(fileSampleSummaryStatistics);
|
||||||
eval$SimpleMetricsBySample = .attemptToLoadFile(fileSimpleMetricsBySample);
|
eval$SimpleMetricsBySample = .gsa.attemptToLoadFile(fileSimpleMetricsBySample);
|
||||||
eval$TiTv = .attemptToLoadFile(fileTi_slash_Tv_Variant_Evaluator);
|
eval$TiTv = .gsa.attemptToLoadFile(fileTi_slash_Tv_Variant_Evaluator);
|
||||||
eval$TiTvStats = .attemptToLoadFile(fileTiTvStats);
|
eval$TiTvStats = .gsa.attemptToLoadFile(fileTiTvStats);
|
||||||
eval$Variant_Quality_Score = .attemptToLoadFile(fileVariant_Quality_Score);
|
eval$Variant_Quality_Score = .gsa.attemptToLoadFile(fileVariant_Quality_Score);
|
||||||
|
|
||||||
uniqueJexlExpressions = unique(eval$TiTv$jexl_expression);
|
uniqueJexlExpressions = unique(eval$TiTv$jexl_expression);
|
||||||
eval$CallsetOnlyNames = as.vector(uniqueJexlExpressions[grep("FilteredIn|Intersection|none", uniqueJexlExpressions, invert=TRUE, ignore.case=TRUE)]);
|
eval$CallsetOnlyNames = as.vector(uniqueJexlExpressions[grep("FilteredIn|Intersection|none", uniqueJexlExpressions, invert=TRUE, ignore.case=TRUE)]);
|
||||||
|
|
@ -69,6 +69,15 @@ function(evalRoot) {
|
||||||
paste(gsub("^(\\w)", "In\\U\\1", eval$CallsetNames[2], perl=TRUE), "-Filtered", gsub("^(\\w)", "In\\U\\1", eval$CallsetNames[1], perl=TRUE), sep=""))
|
paste(gsub("^(\\w)", "In\\U\\1", eval$CallsetNames[2], perl=TRUE), "-Filtered", gsub("^(\\w)", "In\\U\\1", eval$CallsetNames[1], perl=TRUE), sep=""))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!(eval$CallsetFilteredNames[1] %in% unique(eval$TiTv$jexl_expression))) {
|
||||||
|
eval$CallsetFilteredNames[1] = paste("In", eval$CallsetNames[1], "-FilteredIn", eval$CallsetNames[2], sep="");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(eval$CallsetFilteredNames[2] %in% unique(eval$TiTv$jexl_expression))) {
|
||||||
|
eval$CallsetFilteredNames[2] = paste("In", eval$CallsetNames[2], "-FilteredIn", eval$CallsetNames[1], sep="");
|
||||||
|
#eval$CallsetFilteredNames[2] = paste(gsub("^(\\w)", "In", eval$CallsetNames[2], perl=TRUE), "-Filtered", gsub("^(\\w)", "In", eval$CallsetNames[1], perl=TRUE), sep="");
|
||||||
|
}
|
||||||
|
|
||||||
eval;
|
eval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# Load a table into the specified environment. Make sure that each new table gets a unique name (this allows one to cat a bunch of tables with the same name together and load them into R without each table overwriting the last.
|
# Load a table into the specified environment. Make sure that each new table gets a unique name (this allows one to cat a bunch of tables with the same name together and load them into R without each table overwriting the last.
|
||||||
.assignGATKTableToEnvironment <- function(tableName, tableHeader, tableRows, tableEnv) {
|
.gsa.assignGATKTableToEnvironment <- function(tableName, tableHeader, tableRows, tableEnv) {
|
||||||
d = data.frame(tableRows, row.names=NULL, stringsAsFactors=FALSE);
|
d = data.frame(tableRows, row.names=NULL, stringsAsFactors=FALSE);
|
||||||
colnames(d) = tableHeader;
|
colnames(d) = tableHeader;
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load all GATKReport tables from a file
|
# Load all GATKReport tables from a file
|
||||||
read.gatkreport <- function(filename) {
|
gsa.read.gatkreport <- function(filename) {
|
||||||
con = file(filename, "r", blocking = TRUE);
|
con = file(filename, "r", blocking = TRUE);
|
||||||
lines = readLines(con);
|
lines = readLines(con);
|
||||||
close(con);
|
close(con);
|
||||||
|
|
@ -57,7 +57,7 @@ read.gatkreport <- function(filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is.na(tableName)) {
|
if (!is.na(tableName)) {
|
||||||
.assignGATKTableToEnvironment(tableName, tableHeader, tableRows, tableEnv);
|
.gsa.assignGATKTableToEnvironment(tableName, tableHeader, tableRows, tableEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
gatkreport = as.list(tableEnv);
|
gatkreport = as.list(tableEnv);
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
read.squidmetrics = function(project, bylane = FALSE) {
|
gsa.read.squidmetrics = function(project, bylane = FALSE) {
|
||||||
suppressMessages(library(ROracle));
|
suppressMessages(library(ROracle));
|
||||||
|
|
||||||
drv = dbDriver("Oracle");
|
drv = dbDriver("Oracle");
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
\name{getargs}
|
\name{gsa.getargs}
|
||||||
\alias{getargs}
|
\alias{gsa.getargs}
|
||||||
\title{
|
\title{
|
||||||
Get script arguments
|
Get script arguments
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ Get script arguments
|
||||||
Get script arguments given a list object specifying arguments and documentation. Can be used in command-line or interactive mode. This is helpful when developing scripts in interactive mode that will eventually become command-line programs. If no arguments are specified or help is requested in command-line mode, the script will print out a usage statement with available arguments and exit.
|
Get script arguments given a list object specifying arguments and documentation. Can be used in command-line or interactive mode. This is helpful when developing scripts in interactive mode that will eventually become command-line programs. If no arguments are specified or help is requested in command-line mode, the script will print out a usage statement with available arguments and exit.
|
||||||
}
|
}
|
||||||
\usage{
|
\usage{
|
||||||
getargs(argspec, doc = NA)
|
gsa.getargs(argspec, doc = NA)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{argspec}{
|
\item{argspec}{
|
||||||
|
|
@ -18,7 +18,7 @@ A list object. Each key is an argument name. The value is another list object
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
If the value provided is NA, the argument is considered required and must be specified when the script is invoked. For command-line mode, this means the argument must be specified on the command-line. In interactive mode, there are two ways of specifying these arguments. First, if a properly formatted list argument called 'cmdargs' is present in the current environment (i.e. the object returned by getargs() from a previous invocation), the value is taken from this object. Otherwise, the argument is prompted for.
|
If the value provided is NA, the argument is considered required and must be specified when the script is invoked. For command-line mode, this means the argument must be specified on the command-line. In interactive mode, there are two ways of specifying these arguments. First, if a properly formatted list argument called 'cmdargs' is present in the current environment (i.e. the object returned by gsa.getargs() from a previous invocation), the value is taken from this object. Otherwise, the argument is prompted for.
|
||||||
}
|
}
|
||||||
|
|
||||||
\item{doc}{
|
\item{doc}{
|
||||||
|
|
@ -50,7 +50,7 @@ argspec = list(
|
||||||
test2 = list(value=2.3e9, doc="Another argument that does stuff")
|
test2 = list(value=2.3e9, doc="Another argument that does stuff")
|
||||||
);
|
);
|
||||||
|
|
||||||
cmdargs = getargs(argspec, doc="My test program");
|
cmdargs = gsa.getargs(argspec, doc="My test program");
|
||||||
|
|
||||||
print(cmdargs$file); # will print '[1] "/my/test.vcf"'
|
print(cmdargs$file); # will print '[1] "/my/test.vcf"'
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
\name{plot.venn}
|
\name{gsa.plot.venn}
|
||||||
\alias{plot.venn}
|
\alias{gsa.plot.venn}
|
||||||
\title{
|
\title{
|
||||||
Plot a proportional venn diagram
|
Plot a proportional venn diagram
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ Plot a proportional venn diagram
|
||||||
Plot a proportional venn diagram (two or three-way venns allowed)
|
Plot a proportional venn diagram (two or three-way venns allowed)
|
||||||
}
|
}
|
||||||
\usage{
|
\usage{
|
||||||
plot.venn(a, b, c = 0, a_and_b, a_and_c = 0, b_and_c = 0, col = c("#FF6342", "#63C6DE", "#ADDE63"), pos = c(0.2, 0.2, 0.8, 0.82), debug = 0)
|
gsa.plot.venn(a, b, c = 0, a_and_b, a_and_c = 0, b_and_c = 0, col = c("#FF6342", "#63C6DE", "#ADDE63"), pos = c(0.2, 0.2, 0.8, 0.82), debug = 0)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{a}{
|
\item{a}{
|
||||||
|
|
@ -64,10 +64,10 @@ Kiran Garimella
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
## Plot a two-way Venn diagram
|
## Plot a two-way Venn diagram
|
||||||
plot.venn(1000, 750, 0, 400);
|
gsa.plot.venn(1000, 750, 0, 400);
|
||||||
|
|
||||||
## Plot a three-way Venn diagram
|
## Plot a three-way Venn diagram
|
||||||
plot.venn(1000, 750, 900, 400, 650, 500);
|
gsa.plot.venn(1000, 750, 900, 400, 650, 500);
|
||||||
}
|
}
|
||||||
% Add one or more standard keywords, see file 'KEYWORDS' in the
|
% Add one or more standard keywords, see file 'KEYWORDS' in the
|
||||||
% R documentation directory.
|
% R documentation directory.
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
\name{read.eval}
|
\name{gsa.read.eval}
|
||||||
\alias{read.eval}
|
\alias{gsa.read.eval}
|
||||||
\title{
|
\title{
|
||||||
Read a VariantEval file
|
Read a VariantEval file
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ Read a VariantEval file
|
||||||
Read a VariantEval file that's output in R format.
|
Read a VariantEval file that's output in R format.
|
||||||
}
|
}
|
||||||
\usage{
|
\usage{
|
||||||
read.eval(evalRoot)
|
gsa.read.eval(evalRoot)
|
||||||
}
|
}
|
||||||
%- maybe also 'usage' for other objects documented here.
|
%- maybe also 'usage' for other objects documented here.
|
||||||
\arguments{
|
\arguments{
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
\name{read.gatkreport}
|
\name{gsa.read.gatkreport}
|
||||||
\alias{read.gatkreport}
|
\alias{gsa.read.gatkreport}
|
||||||
\title{
|
\title{
|
||||||
read.gatkreport
|
gsa.read.gatkreport
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Reads a GATKReport file - a multi-table document - and loads each table as a separate data.frame object in a list.
|
Reads a GATKReport file - a multi-table document - and loads each table as a separate data.frame object in a list.
|
||||||
}
|
}
|
||||||
\usage{
|
\usage{
|
||||||
read.gatkreport(filename)
|
gsa.read.gatkreport(filename)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{filename}{
|
\item{filename}{
|
||||||
|
|
@ -50,6 +50,6 @@ Kiran Garimella
|
||||||
%% ~~objects to See Also as \code{\link{help}}, ~~~
|
%% ~~objects to See Also as \code{\link{help}}, ~~~
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
report = read.gatkreport("/path/to/my/output.gatkreport");
|
report = gsa.read.gatkreport("/path/to/my/output.gatkreport");
|
||||||
}
|
}
|
||||||
\keyword{ ~kwd1 }
|
\keyword{ ~kwd1 }
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
\name{read.squidmetrics}
|
\name{gsa.read.squidmetrics}
|
||||||
\alias{read.squidmetrics}
|
\alias{gsa.read.squidmetrics}
|
||||||
\title{
|
\title{
|
||||||
read.squidmetrics
|
gsa.read.squidmetrics
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Reads metrics for a specified SQUID project into a dataframe.
|
Reads metrics for a specified SQUID project into a dataframe.
|
||||||
}
|
}
|
||||||
\usage{
|
\usage{
|
||||||
read.squidmetrics("C315")
|
gsa.read.squidmetrics("C315")
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{project}{
|
\item{project}{
|
||||||
|
|
@ -43,6 +43,6 @@ This method will only work within the Broad Institute internal network.
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
## Obtain metrics for project C315.
|
## Obtain metrics for project C315.
|
||||||
d = read.squidmetrics("C315");
|
d = gsa.read.squidmetrics("C315");
|
||||||
}
|
}
|
||||||
\keyword{ ~kwd1 }
|
\keyword{ ~kwd1 }
|
||||||
|
|
@ -25,7 +25,7 @@ GATK help forum: http://www.getsatisfaction.com/gsa
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
## get script arguments in interactive and non-interactive mode
|
## get script arguments in interactive and non-interactive mode
|
||||||
cmdargs = getargs( list(
|
cmdargs = gsa.getargs( list(
|
||||||
requiredArg1 = list(
|
requiredArg1 = list(
|
||||||
value = NA,
|
value = NA,
|
||||||
doc = "Documentation for requiredArg1"
|
doc = "Documentation for requiredArg1"
|
||||||
|
|
@ -38,10 +38,10 @@ cmdargs = getargs( list(
|
||||||
) );
|
) );
|
||||||
|
|
||||||
## plot a proportional Venn diagram
|
## plot a proportional Venn diagram
|
||||||
plot.venn(500, 250, 0, 100);
|
gsa.plot.venn(500, 250, 0, 100);
|
||||||
|
|
||||||
## read a GATKReport file
|
## read a GATKReport file
|
||||||
report = gatk.report("/path/to/my/output.gatkreport");
|
report = gsa.gatk.report("/path/to/my/output.gatkreport");
|
||||||
|
|
||||||
## emit a message
|
## emit a message
|
||||||
gsa.message("This is a message");
|
gsa.message("This is a message");
|
||||||
|
|
@ -51,5 +51,18 @@ gsa.message("This is a warning message");
|
||||||
|
|
||||||
## emit an error message
|
## emit an error message
|
||||||
gsa.message("This is an error message");
|
gsa.message("This is an error message");
|
||||||
|
|
||||||
|
## read the SQUID metrics for a given sequencing project (internal to the Broad only)
|
||||||
|
s = gsa.read.squidmetrics("C427");
|
||||||
|
|
||||||
|
## read command-line arguments
|
||||||
|
cmdargs = gsa.getargs(
|
||||||
|
list(
|
||||||
|
file = list(value="/my/test.vcf", doc="VCF file"),
|
||||||
|
verbose = list(value=0, doc="If 1, set verbose mode"),
|
||||||
|
test2 = list(value=2.3e9, doc="Another argument that does stuff")
|
||||||
|
),
|
||||||
|
doc="My test program"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
\keyword{ package }
|
\keyword{ package }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue