# HG changeset patch # User blankenberglab # Date 1543334566 18000 # Node ID d93629e79f5edcb5da7b928b3660a9d3919ac6cc # Parent ed24bacaa4d00ca4934ba5a49ffc332d80392070 planemo upload for repository https://github.com/blankenberglab/galaxy-tools-blankenberg/tree/master/tools/r-gpca commit 3b791d44853d8928046914cd93112bdcf89d4965 diff -r ed24bacaa4d0 -r d93629e79f5e r-gpca.R --- a/r-gpca.R Mon Nov 19 10:15:19 2018 -0500 +++ b/r-gpca.R Tue Nov 27 11:02:46 2018 -0500 @@ -1,6 +1,7 @@ #!/usr/bin/env Rscript library(optparse) library(gPCA) +options(bitmapType='cairo') # parse options @@ -105,82 +106,92 @@ stop((paste('File for data', opt$data, 'does not exist'))) } -batch<-as.numeric(factor(as.matrix(read.delim(opt$batch, header=TRUE, row.names=1, sep="\t")))) - +dir.create(opt$path); data<-t(as.matrix(read.delim(opt$data, row.names=1, header=TRUE, sep="\t"))) +batch<-as.matrix(read.delim(opt$batch, header=TRUE, row.names=1, sep="\t")) -out<-gPCA.batchdetect(x=data, batch=batch, center=opt$center, scaleY=opt$scaleY, nperm=opt$nperm, filt=opt$filt, seed=opt$seed) +write('',file = opt$html_outfile, append=TRUE) +write('#Batch\tDelta\tP-value\tCumulative Variance',file = opt$numbers_outfile, append=TRUE) +write('

Table of Contents

', file=opt$html_outfile, append=TRUE) + +for (row in 1:nrow(batch)) { + write(paste0('
  • ',row.names(batch)[row],'
  • '), file=opt$html_outfile, append=TRUE) +} +for (row in 1:nrow(batch)) { + batch1<-as.numeric(factor(batch[row,])) + +out<-gPCA.batchdetect(x=data, batch=batch1, center=opt$center, scaleY=opt$scaleY, nperm=opt$nperm, filt=opt$filt, seed=opt$seed) out$varPCg1<-((out$varPCg1-out$varPCu1)/out$varPCg1)*100 -dir.create(opt$path); - -write.table(data.frame(out$delta, out$p.val, out$varPCg1),file=opt$numbers_outfile, sep="\t", row.name=FALSE, quote=FALSE) +write(paste(row.names(batch)[row],out$delta,out$p.val,out$varPCg1,sep="\t"),file = opt$numbers_outfile, append=TRUE) # General Distribution par(mai=c(0.8,0.8,0.1,0.1),cex=0.8) -png(paste(opt$path,'/gDist.png', sep=""), width=1020, height=800, units='px') +png(paste(opt$path,'/gDist_',row,'.png', sep=""), width=1020, height=800, units='px') gDist(out) invisible(dev.off()) # Guided/Unguided 1v2 par(mai=c(0.8,0.8,0.1,0.1),cex=0.8) -png(paste(opt$path,'/guided_1v2.png', sep=""), width=1020, height=800, units='px') +png(paste(opt$path,'/guided_1v2_',row,'.png', sep=""), width=1020, height=800, units='px') PCplot(out,ug="unguided",type="1v2") invisible(dev.off()) par(mai=c(0.8,0.8,0.1,0.1),cex=0.8) -png(paste(opt$path,'/unguided_1v2.png', sep=""), width=1020, height=800, units='px') +png(paste(opt$path,'/unguided_1v2_',row,'.png', sep=""), width=1020, height=800, units='px') PCplot(out,ug="unguided",type="1v2") invisible(dev.off()) # Guided/Unguided comp,3 par(mai=c(0.65,0.65,0.1,0.1),cex=0.8) -png(paste(opt$path,'/guided_npcs.png', sep=""), width=1020, height=800, units='px') +png(paste(opt$path,'/guided_npcs_',row,'.png', sep=""), width=1020, height=800, units='px') PCplot(out,ug="guided",type="comp",npcs=opt$npcs) invisible(dev.off()) par(mai=c(0.65,0.65,0.1,0.1),cex=0.8) -png(paste(opt$path,'/unguided_npcs.png', sep=""), width=1020, height=800, units='px') +png(paste(opt$path,'/unguided_npcs_',row,'.png', sep=""), width=1020, height=800, units='px') PCplot(out,ug="unguided",type="comp",npcs=opt$npcs) invisible(dev.off()) # Guided/Unguided CumlativeVarPlot par(mai=c(0.8,0.8,0.1,0.1),cex=0.8) -png(paste(opt$path,'/guided_var.png', sep=""), width=1020, height=800, units='px') +png(paste(opt$path,'/guided_var_',row,'.png', sep=""), width=1020, height=800, units='px') CumulativeVarPlot(out,ug="guided",col="blue") invisible(dev.off()) par(mai=c(0.8,0.8,0.1,0.1),cex=0.8) -png(paste(opt$path,'/unguided_var.png', sep=""), width=1020, height=800, units='px') +png(paste(opt$path,'/unguided_var_',row,'.png', sep=""), width=1020, height=800, units='px') CumulativeVarPlot(out,ug="unguided",col="blue") invisible(dev.off()) -write(paste(' - +write(paste0(' +
    ',row.names(batch)[row],'
    +
    +
    - +
    DeltaP-valuevarPCg1
    ',out$delta,'',out$p.val,'',out$varPCg1,'',out$delta,'',out$p.val,'',out$varPCg1,'
    +

    +
    Guided 1v2

    +
    Unguided 1v2

    -

    -
    Guided 1v2

    -
    Unguided 1v2

    +
    Guided Compare to ',opt$npcs,'

    +
    Unguided Compare to ',opt$npcs,'

    -
    Guided Compare to ',opt$npcs,'

    -
    Unguided Compare to ',opt$npcs,'

    +
    Guided Cumulative Variance

    +
    Unguided Cumulative Variance

    -
    Guided Cumulative Variance

    -
    Unguided Cumulative Variance

    - -' -),file = opt$html_outfile) +'), file = opt$html_outfile, append=TRUE) +} +write(paste('

    Back to Top

    '),file = opt$html_outfile, append=TRUE) sessionInfo() diff -r ed24bacaa4d0 -r d93629e79f5e r-gpca.xml --- a/r-gpca.xml Mon Nov 19 10:15:19 2018 -0500 +++ b/r-gpca.xml Tue Nov 27 11:02:46 2018 -0500 @@ -35,7 +35,7 @@ - + @@ -54,16 +54,43 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -88,11 +115,20 @@ seed: the seed number for set.seed(). Default is NULL. - Literature: + npcs: number of principal components to calculate + + **Literature** https://cran.r-project.org/web/packages/gPCA/gPCA.pdf https://cran.r-project.org/web/packages/gPCA/vignettes/gPCA.pdf + + **Input File Help** + + Batch: The batch file must be a tab delimited file. It will be read as a numeric vector, consisting of as many different batches as you like. The test data file batch_in_multiple_1.tabular shows the correct format. The length of batch must conform to the data matrix or an error will occur. + + Data: The data file must be a tab delimited file. It will be read in as a matrix. The test data file data_in_1.tabular shows the correct format. If you are receving errors about nonconformed matrices in your matrix you might need to transpose your matrix before using it in the tool. + ]]> diff -r ed24bacaa4d0 -r d93629e79f5e test-data/batch_in_multiple_1.tabular --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/batch_in_multiple_1.tabular Tue Nov 27 11:02:46 2018 -0500 @@ -0,0 +1,3 @@ +#batch sample_1 sample_2 sample_3 sample_4 sample_5 sample_6 sample_7 sample_8 sample_9 sample_10 +time_period batch_1 batch_3 batch_3 batch_3 batch_2 batch_2 batch_1 batch_2 batch_3 batch_3 +random_batch b a c a a c b a c a \ No newline at end of file diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/gDist.png Binary file test-data/html_outfile_1/gDist.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/gDist_1.png Binary file test-data/html_outfile_1/gDist_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/guided_1v2.png Binary file test-data/html_outfile_1/guided_1v2.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/guided_1v2_1.png Binary file test-data/html_outfile_1/guided_1v2_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/guided_npcs.png Binary file test-data/html_outfile_1/guided_npcs.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/guided_npcs_1.png Binary file test-data/html_outfile_1/guided_npcs_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/guided_var.png Binary file test-data/html_outfile_1/guided_var.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/guided_var_1.png Binary file test-data/html_outfile_1/guided_var_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/html_outfile_1.html --- a/test-data/html_outfile_1/html_outfile_1.html Mon Nov 19 10:15:19 2018 -0500 +++ b/test-data/html_outfile_1/html_outfile_1.html Tue Nov 27 11:02:46 2018 -0500 @@ -1,21 +1,26 @@ - - + +

    Table of Contents

    +
  • time_period
  • + +
    time_period
    +
    +
    - +
    DeltaP-valuevarPCg1
    0.824447005030577 0.512 20.6295699072817 0.8244470050305770.51220.6295699072817
    - -

    -
    Guided 1v2

    -
    Unguided 1v2

    +

    +
    Guided 1v2

    +
    Unguided 1v2

    -
    Guided Compare to 3

    -
    Unguided Compare to 3

    +
    Guided Compare to 3

    +
    Unguided Compare to 3

    -
    Guided Cumulative Variance

    -
    Unguided Cumulative Variance

    +
    Guided Cumulative Variance

    +
    Unguided Cumulative Variance

    - + +

    Back to Top

    diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/unguided_1v2.png Binary file test-data/html_outfile_1/unguided_1v2.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/unguided_1v2_1.png Binary file test-data/html_outfile_1/unguided_1v2_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/unguided_npcs.png Binary file test-data/html_outfile_1/unguided_npcs.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/unguided_npcs_1.png Binary file test-data/html_outfile_1/unguided_npcs_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/unguided_var.png Binary file test-data/html_outfile_1/unguided_var.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_1/unguided_var_1.png Binary file test-data/html_outfile_1/unguided_var_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/gDist_1.png Binary file test-data/html_outfile_2/gDist_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/gDist_2.png Binary file test-data/html_outfile_2/gDist_2.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/guided_1v2_1.png Binary file test-data/html_outfile_2/guided_1v2_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/guided_1v2_2.png Binary file test-data/html_outfile_2/guided_1v2_2.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/guided_npcs_1.png Binary file test-data/html_outfile_2/guided_npcs_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/guided_npcs_2.png Binary file test-data/html_outfile_2/guided_npcs_2.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/guided_var_1.png Binary file test-data/html_outfile_2/guided_var_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/guided_var_2.png Binary file test-data/html_outfile_2/guided_var_2.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/html_outfile_2.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/html_outfile_2/html_outfile_2.html Tue Nov 27 11:02:46 2018 -0500 @@ -0,0 +1,49 @@ + +

    Table of Contents

    +
  • time_period
  • +
  • random_batch
  • + +
    time_period
    +
    + + + + + + + +
    DeltaP-valuevarPCg1
    0.8244470050305770.51220.6295699072817
    +

    +
    Guided 1v2

    +
    Unguided 1v2

    + +
    Guided Compare to 3

    +
    Unguided Compare to 3

    + +
    Guided Cumulative Variance

    +
    Unguided Cumulative Variance

    + + + +
    random_batch
    +
    + + + + + + + +
    DeltaP-valuevarPCg1
    0.977890001737870.08619.260564791629
    +

    +
    Guided 1v2

    +
    Unguided 1v2

    + +
    Guided Compare to 3

    +
    Unguided Compare to 3

    + +
    Guided Cumulative Variance

    +
    Unguided Cumulative Variance

    + + +

    Back to Top

    diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/unguided_1v2_1.png Binary file test-data/html_outfile_2/unguided_1v2_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/unguided_1v2_2.png Binary file test-data/html_outfile_2/unguided_1v2_2.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/unguided_npcs_1.png Binary file test-data/html_outfile_2/unguided_npcs_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/unguided_npcs_2.png Binary file test-data/html_outfile_2/unguided_npcs_2.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/unguided_var_1.png Binary file test-data/html_outfile_2/unguided_var_1.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/html_outfile_2/unguided_var_2.png Binary file test-data/html_outfile_2/unguided_var_2.png has changed diff -r ed24bacaa4d0 -r d93629e79f5e test-data/numbers_outfile_1.tabular --- a/test-data/numbers_outfile_1.tabular Mon Nov 19 10:15:19 2018 -0500 +++ b/test-data/numbers_outfile_1.tabular Tue Nov 27 11:02:46 2018 -0500 @@ -1,2 +1,2 @@ -out.delta out.p.val out.varPCg1 -0.824447005030577 0.512 20.6295699072817 +#Batch Delta P-value Cumulative Variance +time_period 0.824447005030577 0.512 20.6295699072817 diff -r ed24bacaa4d0 -r d93629e79f5e test-data/numbers_outfile_2.tabular --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/numbers_outfile_2.tabular Tue Nov 27 11:02:46 2018 -0500 @@ -0,0 +1,3 @@ +#Batch Delta P-value Cumulative Variance +time_period 0.824447005030577 0.512 20.6295699072817 +random_batch 0.97789000173787 0.086 19.260564791629