Mercurial > repos > blankenberglab > gpca
changeset 3:8def7dda3bee draft
planemo upload for repository https://github.com/blankenberglab/galaxy-tools-blankenberg/tree/master/tools/r-gpca commit f5a03b0978b3a7473f034b87a87765ff1d65d720
| author | blankenberglab |
|---|---|
| date | Mon, 03 Dec 2018 15:04:08 -0500 |
| parents | 4865e7f4e9c5 |
| children | ceaa4d404115 |
| files | r-gpca.R r-gpca.xml test-data/html_outfile_1/html_outfile_1.html test-data/html_outfile_2/html_outfile_2.html |
| diffstat | 4 files changed, 146 insertions(+), 98 deletions(-) [+] |
line wrap: on
line diff
--- a/r-gpca.R Tue Nov 27 12:29:58 2018 -0500 +++ b/r-gpca.R Mon Dec 03 15:04:08 2018 -0500 @@ -3,7 +3,6 @@ library(gPCA) options(bitmapType='cairo') - # parse options option_list = list( make_option( @@ -38,7 +37,7 @@ action = "store_true", default = FALSE, help = "Is the input batch and data centered [default %default]" - ), + ), make_option( c("-y", "--scaleY"), action = "store_true", @@ -51,7 +50,7 @@ default = NULL, type = 'numeric', help = "Retain features" - ), + ), make_option( c( "--npcs"), action = "store", @@ -79,7 +78,7 @@ default = NA, type = 'character', help = "Numbers output" - ), + ), make_option( c("-o", "--html_outfile"), action = "store", @@ -98,7 +97,6 @@ } # Check parameter values - if ( ! file.exists(opt$batch)){ stop((paste('File for batch', opt$batch, 'does not exist'))) } @@ -111,20 +109,38 @@ batch<-as.matrix(read.delim(opt$batch, header=TRUE, row.names=1, sep="\t")) write('#Batch\tDelta\tP-value\tCumulative Variance',file = opt$numbers_outfile, append=TRUE) +write('<!DOCTYPE html> + <html lang="en"> + <head> + <style> + table, td, th { + margin-left:auto; + margin-right:auto; + border: 2px solid black; + } + h2, ul { + text-align:left; + } + h1 { + text-align:center; + } + body { + text-align: center; + } + p { + font-size: 0px; + } + </style> + <title>HTML gPCA</title></head><body><p>If you are seeing this then CSS is not whitelisted</p><h2 id = "top">Table of Contents</h2><ul>', file = opt$html_outfile, append=TRUE) -write('<html><body><div align="left" id="top"><p><h1>Table of Contents</h1><ul>',file = opt$html_outfile, append=TRUE) for (row in 1:nrow(batch)) { write(paste0('<li><a href="#',row.names(batch)[row],'">',row.names(batch)[row],'</a></li>'), file=opt$html_outfile, append=TRUE) } -write('</ul></p></div>', file=opt$html_outfile, append=TRUE) - +write('</ul>', 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 - write(paste(row.names(batch)[row],out$delta,out$p.val,out$varPCg1,sep="\t"),file = opt$numbers_outfile, append=TRUE) # General Distribution @@ -133,66 +149,55 @@ 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_',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_',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_',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_',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_',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_',row,'.png', sep=""), width=1020, height=800, units='px') CumulativeVarPlot(out,ug="unguided",col="blue") invisible(dev.off()) - write(paste0(' -<header id=',row.names(batch)[row],'><center><font size="11">',row.names(batch)[row],'</font><center></header> -<br> -<table align="center" border="1"> +<h1 id="',row.names(batch)[row],'">',row.names(batch)[row],'</h1> +<br> +<table> <tr> <th>Delta</th><th>P-value</th><th>varPCg1</th> </tr> <tr> - <td id="#">',out$delta,'</td><td id=p.val>',out$p.val,'</td><td id=varPCg1>',out$varPCg1,'</td> + <td>',out$delta,' </td><td>',out$p.val,' </td><td>',out$varPCg1,'</td> </tr> -</table> -<center><img src="gDist_',row,'.png"/></center><br> -<center><title>Guided 1v2</title><br><img src="guided_1v2_',row,'.png"/></center><br> -<center><title>Unguided 1v2</title><br><img src="unguided_1v2_',row,'.png"/></center><br> - -<center><title>Guided Compare to ',opt$npcs,'</title><br><img src="guided_npcs_',row,'.png"/></center><br> -<center><title>Unguided Compare to ',opt$npcs,'</title><br><img src="unguided_npcs_',row,'.png"/></center><br> - -<center><title>Guided Cumulative Variance</title><br><img src="guided_var_',row,'.png"/></center><br> -<center><title>Unguided Cumulative Variance</title><br><img src="unguided_var_',row,'.png"/></center><br> - +</table><br> +<h3>gDist</h3><br><img src="gDist_',row,'.png" alt="gDist"/> +<br> +<h3>Guided 1v2</h3><br><img src="guided_1v2_',row,'.png" alt="guided_1v2" /><br> +<h3>Unguided 1v2</h3><br><img src="unguided_1v2_',row,'.png" alt="unguided_1v2" /><br> +<h3>Guided Compare to ',opt$npcs,'</h3><br><img src="guided_npcs_',row,'.png" alt="guided_npcs"/><br> +<h3>Unguided Compare to ',opt$npcs,'</h3><br><img src="unguided_npcs_',row,'.png" alt="unguided_npcs"/><br> +<h3>Guided Cumulative Variance</h3><br><img src="guided_var_',row,'.png" alt="guided_var" /><br> +<h3>Unguided Cumulative Variance</h3><br><img src="unguided_var_',row,'.png" alt="unguided_var" /><br> '), file = opt$html_outfile, append=TRUE) } -write(paste('<p><center><a href="#top">Back to Top</a></center></p></body></html>'),file = opt$html_outfile, append=TRUE) - -sessionInfo() +write(paste('<a href="#top">Back to Top</a></body></html>'),file = opt$html_outfile, append=TRUE)
--- a/r-gpca.xml Tue Nov 27 12:29:58 2018 -0500 +++ b/r-gpca.xml Mon Dec 03 15:04:08 2018 -0500 @@ -56,13 +56,16 @@ <output name="html_outfile" ftype="html" file="html_outfile_1/html_outfile_1.html"> <extra_files type="file" name="gDist_1.png" value="html_outfile_1/gDist_1.png" compare="sim_size"/> <extra_files type="file" name="guided_1v2_1.png" value="html_outfile_1/guided_1v2_1.png" compare="sim_size"/> - <extra_files type="file" name="unguided_1v2_1.png" value="html_outfile_1/unguided_1v2_1.png" compare="sim_size"/> + <extra_files type="file" name="unguided_1v2_1.png" value="html_outfile_1/unguided_1v2_1.png" + compare="sim_size"/> <extra_files type="file" name="guided_npcs_1.png" value="html_outfile_1/guided_npcs_1.png" compare="sim_size"/> - <extra_files type="file" name="unguided_npcs_1.png" value="html_outfile_1/unguided_npcs_1.png" compare="sim_size"/> + <extra_files type="file" name="unguided_npcs_1.png" value="html_outfile_1/unguided_npcs_1.png" + compare="sim_size"/> <extra_files type="file" name="guided_var_1.png" value="html_outfile_1/guided_var_1.png" compare="sim_size"/> - <extra_files type="file" name="unguided_var_1.png" value="html_outfile_1/unguided_var_1.png" compare="sim_size"/> + <extra_files type="file" name="unguided_var_1.png" value="html_outfile_1/unguided_var_1.png" + compare="sim_size"/> </output> - <output name="numbers_outfile" ftype="tabular" file="numbers_outfile_1.tabular"/> + <output name="numbers_outfile_1.tabular" ftype="tabular" file="numbers_outfile_1.tabular"/> </test> <test> <param name="batch" ftype="tabular" value="batch_in_multiple_1.tabular" /> @@ -78,18 +81,22 @@ <extra_files type="file" name="gDist_2.png" value="html_outfile_2/gDist_2.png" compare="sim_size"/> <extra_files type="file" name="guided_1v2_1.png" value="html_outfile_2/guided_1v2_1.png" compare="sim_size"/> <extra_files type="file" name="guided_1v2_2.png" value="html_outfile_2/guided_1v2_2.png" compare="sim_size"/> - <extra_files type="file" name="unguided_1v2_1.png" value="html_outfile_2/unguided_1v2_1.png" compare="sim_size"/> - <extra_files type="file" name="unguided_1v2_2.png" value="html_outfile_2/unguided_1v2_2.png" compare="sim_size"/> + <extra_files type="file" name="unguided_1v2_1.png" value="html_outfile_2/unguided_1v2_1.png" + compare="sim_size"/> + <extra_files type="file" name="unguided_1v2_2.png" value="html_outfile_2/unguided_1v2_2.png" + compare="sim_size"/> <extra_files type="file" name="guided_npcs_1.png" value="html_outfile_2/guided_npcs_1.png" compare="sim_size"/> <extra_files type="file" name="guided_npcs_2.png" value="html_outfile_2/guided_npcs_2.png" compare="sim_size"/> <extra_files type="file" name="unguided_npcs_1.png" value="html_outfile_2/unguided_npcs_1.png" compare="sim_size"/> <extra_files type="file" name="unguided_npcs_2.png" value="html_outfile_2/unguided_npcs_2.png" compare="sim_size"/> <extra_files type="file" name="guided_var_1.png" value="html_outfile_2/guided_var_1.png" compare="sim_size"/> <extra_files type="file" name="guided_var_2.png" value="html_outfile_2/guided_var_2.png" compare="sim_size"/> - <extra_files type="file" name="unguided_var_1.png" value="html_outfile_2/unguided_var_1.png" compare="sim_size"/> - <extra_files type="file" name="unguided_var_2.png" value="html_outfile_2/unguided_var_2.png" compare="sim_size"/> + <extra_files type="file" name="unguided_var_1.png" value="html_outfile_2/unguided_var_1.png" + compare="sim_size"/> + <extra_files type="file" name="unguided_var_2.png" value="html_outfile_2/unguided_var_2.png" + compare="sim_size"/> </output> - <output name="numbers_outfile" ftype="tabular" file="numbers_outfile_2.tabular"/> + <output name="numbers_outfile_2.tabular" ftype="tabular" file="numbers_outfile_2.tabular"/> </test> </tests> @@ -118,13 +125,11 @@ 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.
--- a/test-data/html_outfile_1/html_outfile_1.html Tue Nov 27 12:29:58 2018 -0500 +++ b/test-data/html_outfile_1/html_outfile_1.html Mon Dec 03 15:04:08 2018 -0500 @@ -1,26 +1,46 @@ -<html><body><a name="top"></a> -<div align="left><ul id =""><p><b>Table of Contents</b></p></ul></div> +<!DOCTYPE html> + <html lang="en"> + <head> + <style> + table, td, th { + margin-left:auto; + margin-right:auto; + border: 2px solid black; + } + h2, ul { + text-align:left; + } + h1 { + text-align:center; + } + body { + text-align: center; + } + p { + font-size: 0px; + } + </style> + <title>HTML gPCA</title></head><body><p>If you are seeing this then CSS is not whitelisted</p><h2 id = "top">Table of Contents</h2><ul> <li><a href="#time_period">time_period</a></li> +</ul> -<header id=time_period><center><font size="11">time_period</font><center></header> -<br> -<table align="center" border="1"> +<h1 id="time_period">time_period</h1> +<br> +<table> <tr> <th>Delta</th><th>P-value</th><th>varPCg1</th> </tr> <tr> - <td id="#">0.824447005030577</td><td id=p.val>0.512</td><td id=varPCg1>20.6295699072817</td> + <td>0.824447005030577 </td><td>0.512 </td><td>20.6295699072817</td> </tr> -</table> -<center><img src="gDist_1.png"/></center><br> -<center><title>Guided 1v2</title><br><img src="guided_1v2_1.png"/></center><br> -<center><title>Unguided 1v2</title><br><img src="unguided_1v2_1.png"/></center><br> +</table><br> +<h3>gDist</h3><br><img src="gDist_1.png" alt="gDist"/> +<br> +<h3>Guided 1v2</h3><br><img src="guided_1v2_1.png" alt="guided_1v2" /><br> +<h3>Unguided 1v2</h3><br><img src="unguided_1v2_1.png" alt="unguided_1v2" /><br> +<h3>Guided Compare to 3</h3><br><img src="guided_npcs_1.png" alt="guided_npcs"/><br> +<h3>Unguided Compare to 3</h3><br><img src="unguided_npcs_1.png" alt="unguided_npcs"/><br> +<h3>Guided Cumulative Variance</h3><br><img src="guided_var_1.png" alt="guided_var" /><br> +<h3>Unguided Cumulative Variance</h3><br><img src="unguided_var_1.png" alt="unguided_var" /><br> -<center><title>Guided Compare to 3</title><br><img src="guided_npcs_1.png"/></center><br> -<center><title>Unguided Compare to 3</title><br><img src="unguided_npcs_1.png"/></center><br> - -<center><title>Guided Cumulative Variance</title><br><img src="guided_var_1.png"/></center><br> -<center><title>Unguided Cumulative Variance</title><br><img src="unguided_var_1.png"/></center><br> - - -<p><center><a href="#top">Back to Top</a></center></p></body></html> +<a href="#top">Back to Top</a></body></html>
--- a/test-data/html_outfile_2/html_outfile_2.html Tue Nov 27 12:29:58 2018 -0500 +++ b/test-data/html_outfile_2/html_outfile_2.html Mon Dec 03 15:04:08 2018 -0500 @@ -1,49 +1,67 @@ -<html><body><a name="top"></a> -<div align="left><ul id =""><p><b>Table of Contents</b></p></ul></div> +<!DOCTYPE html> + <html lang="en"> + <head> + <style> + table, td, th { + margin-left:auto; + margin-right:auto; + border: 2px solid black; + } + h2, ul { + text-align:left; + } + h1 { + text-align:center; + } + body { + text-align: center; + } + p { + font-size: 0px; + } + </style> + <title>HTML gPCA</title></head><body><p>If you are seeing this then CSS is not whitelisted</p><h2 id = "top">Table of Contents</h2><ul> <li><a href="#time_period">time_period</a></li> <li><a href="#random_batch">random_batch</a></li> +</ul> -<header id=time_period><center><font size="11">time_period</font><center></header> -<br> -<table align="center" border="1"> +<h1 id="time_period">time_period</h1> +<br> +<table> <tr> <th>Delta</th><th>P-value</th><th>varPCg1</th> </tr> <tr> - <td id="#">0.824447005030577</td><td id=p.val>0.512</td><td id=varPCg1>20.6295699072817</td> + <td>0.824447005030577 </td><td>0.512 </td><td>20.6295699072817</td> </tr> -</table> -<center><img src="gDist_1.png"/></center><br> -<center><title>Guided 1v2</title><br><img src="guided_1v2_1.png"/></center><br> -<center><title>Unguided 1v2</title><br><img src="unguided_1v2_1.png"/></center><br> - -<center><title>Guided Compare to 3</title><br><img src="guided_npcs_1.png"/></center><br> -<center><title>Unguided Compare to 3</title><br><img src="unguided_npcs_1.png"/></center><br> - -<center><title>Guided Cumulative Variance</title><br><img src="guided_var_1.png"/></center><br> -<center><title>Unguided Cumulative Variance</title><br><img src="unguided_var_1.png"/></center><br> +</table><br> +<h3>gDist</h3><br><img src="gDist_1.png" alt="gDist"/> +<br> +<h3>Guided 1v2</h3><br><img src="guided_1v2_1.png" alt="guided_1v2" /><br> +<h3>Unguided 1v2</h3><br><img src="unguided_1v2_1.png" alt="unguided_1v2" /><br> +<h3>Guided Compare to 3</h3><br><img src="guided_npcs_1.png" alt="guided_npcs"/><br> +<h3>Unguided Compare to 3</h3><br><img src="unguided_npcs_1.png" alt="unguided_npcs"/><br> +<h3>Guided Cumulative Variance</h3><br><img src="guided_var_1.png" alt="guided_var" /><br> +<h3>Unguided Cumulative Variance</h3><br><img src="unguided_var_1.png" alt="unguided_var" /><br> - -<header id=random_batch><center><font size="11">random_batch</font><center></header> -<br> -<table align="center" border="1"> +<h1 id="random_batch">random_batch</h1> +<br> +<table> <tr> <th>Delta</th><th>P-value</th><th>varPCg1</th> </tr> <tr> - <td id="#">0.97789000173787</td><td id=p.val>0.086</td><td id=varPCg1>19.260564791629</td> + <td>0.97789000173787 </td><td>0.086 </td><td>19.260564791629</td> </tr> -</table> -<center><img src="gDist_2.png"/></center><br> -<center><title>Guided 1v2</title><br><img src="guided_1v2_2.png"/></center><br> -<center><title>Unguided 1v2</title><br><img src="unguided_1v2_2.png"/></center><br> +</table><br> +<h3>gDist</h3><br><img src="gDist_2.png" alt="gDist"/> +<br> +<h3>Guided 1v2</h3><br><img src="guided_1v2_2.png" alt="guided_1v2" /><br> +<h3>Unguided 1v2</h3><br><img src="unguided_1v2_2.png" alt="unguided_1v2" /><br> +<h3>Guided Compare to 3</h3><br><img src="guided_npcs_2.png" alt="guided_npcs"/><br> +<h3>Unguided Compare to 3</h3><br><img src="unguided_npcs_2.png" alt="unguided_npcs"/><br> +<h3>Guided Cumulative Variance</h3><br><img src="guided_var_2.png" alt="guided_var" /><br> +<h3>Unguided Cumulative Variance</h3><br><img src="unguided_var_2.png" alt="unguided_var" /><br> -<center><title>Guided Compare to 3</title><br><img src="guided_npcs_2.png"/></center><br> -<center><title>Unguided Compare to 3</title><br><img src="unguided_npcs_2.png"/></center><br> - -<center><title>Guided Cumulative Variance</title><br><img src="guided_var_2.png"/></center><br> -<center><title>Unguided Cumulative Variance</title><br><img src="unguided_var_2.png"/></center><br> - - -<p><center><a href="#top">Back to Top</a></center></p></body></html> +<a href="#top">Back to Top</a></body></html>
