## useage: $ Useage: R CMD BATCH '--args infile= column= classes=' hist_from_table.R ## PART ONE: read in and store the table ## # get the command line arguments i.e. the name of the file containing the table to read args=(commandArgs(TRUE)) if(length(args)==0){ # if arguments are not passed . . . cat("Useage: R CMD BATCH '--args infile= column= burnin= classes=' hist_from_table.R\n") infile <- 'Fitch_HA.nex.p' # assume the input file name column <- 5 burnin <- 50000 classes <- 50 } else { for(i in 1:length(args)){ eval(parse(text=args[[i]])) } } # open the table and store it as a dataframe data <- read.table(infile, header = TRUE) ## PART TWO: plot a histogram of the selected column # this makes some histograms in a PDF (Adobe Portable Document Format, can be viewed in Adobe Reader etc) # <- this symbol makes R ignore the rest of the line. This is useful for adding comments or 'commenting out' R commands so they are silent and do not run # deleting the '#' symbol means R will be read and attempt to execute everything until the next '#' or the next line # open a PDF file to write in pdf(file=paste('MB_plots_',names(data)[column],'.pdf',sep=''), title='Plots from MrBayes Posterior Distribution table') # plot a histogram of the selected column hist(data[data$Gen>burnin,column], main = paste('Histogram of',names(data)[column],'parameter of MrBayes Bayesian search'), nclass = classes, col = 'Red', xlab = names(data)[column]) # close the PDF file making it readable dev.off() # General reference: # these are the columns in a BLAST output table # 1:query name # 2:subject name # 3:percent identities # 4:aligned length # 5:number of mismatched positions # 6:number of gap positions # 7:query sequence start # 8:query sequence end # 9:subject sequence start # 10:subject sequence end # 11: e-value # 12: bit score