Genome-Model-Tools-Music
view release on metacpan or search on metacpan
lib/Genome/Model/Tools/Music/ClinicalCorrelation.pm.R view on Meta::CPAN
# x.file="*" if x.file already merged into y.file
### about x.names
# x.names="*" will use all column names in x.file as x variable names
# or you can define it in the format x.names="gene1|gene2|gene3"
# self-defined x.names have to be found in column names of y.file and/or x.file
#################### myglm fuction ##############
myglm=function(z,trait,variant,covar=NA,ytype) {
if (nchar(covar)==0 | is.na(covar) | is.null(covar)) {
model=formula(paste(trait,"~",variant))
} else {
model=formula(paste(trait,"~",variant,"+",covar))
}
if (ytype=="B") fit=glm(formula=model,data=z,family=binomial(link = "logit"))
if (ytype=="Q") fit=glm(formula=model,data=z,family=gaussian(link = "identity"))
fit
}
#################################################
### data input #####
read.table(model.file,colClasses="character",na.strings = c("","NA"),sep="\t",header=T)->md
read.table(y.file,na.strings = c("","NA"),sep="\t",header=T)->y
if (x.names!="*") x.names=strsplit(x.names,split="[|]")[[1]]
lib/Genome/Model/Tools/Music/Plot/MutationRelation.pm.R view on Meta::CPAN
# Fetch command line arguments
args = commandArgs();
input_matrix = as.character(args[4]);
genes_to_plot = as.character(args[5]);
output_pdf = as.character(args[6]);
preserveGeneOrder = as.numeric(as.character(args[7]));
sort.data.frame <- function( x, by ) {
if(by[[1]] != "~")
stop("Argument 'by' must be a one-sided formula.")
## Make the formula into character and remove spaces
formc <- as.character(by[2])
formc <- gsub(" ", "", formc)
## If the first character is not + or -, add +
if(!is.element(substring(formc, 1, 1), c("+", "-")))
formc <- paste("+", formc, sep = "")
## Extract the variables from the formula
vars <- unlist(strsplit(formc, "[\\+\\-]"))
vars <- vars[vars != ""] # Remove any extra "" terms
## Build a list of arguments to pass to "order" function
calllist <- list()
pos <- 1 # Position of + or -
for(i in 1:length(vars)){
varsign <- substring(formc, pos, pos)
pos <- pos + 1 + nchar(vars[i])
if(is.factor(x[, vars[i]])){
( run in 0.245 second using v1.01-cache-2.11-cpan-26ccb49234f )