# HG changeset patch # User nikos # Date 1415141682 18000 # Node ID 2ae336f19de08104ba4a733760b0d292deede6cb # Parent 6b9e957d8db1d7f41359c282d3959e48897ac43a Uploaded diff -r 6b9e957d8db1 -r 2ae336f19de0 k2n.R --- a/k2n.R Tue Nov 04 15:11:36 2014 -0500 +++ b/k2n.R Tue Nov 04 17:54:42 2014 -0500 @@ -3,35 +3,14 @@ options(stringAsfactors = FALSE, useFancyQuotes = FALSE) args <- commandArgs(trailingOnly = TRUE) -#get options, using the spec as defined by the enclosed list. -#we read the options from the default: commandArgs(TRUE). -spec = matrix( c( - 'verbose', 'v', 2, "integer", - 'help' , 'h', 0, "logical", - 'merged', 'm', 1, "character", - 'read_counts', 'c', 1, "character", - 'max_observed', 'b', 1, "integer", - 'barcode_length', 'l', 1, "integer", - 'output', 'o', 1, "character" - ), byrow = TRUE, ncol = 4 ); - -opt = getopt( spec ); - -# if help was asked for print a friendly message -# and exit with a non-zero error code -if ( !is.null( opt$help ) ) { - cat( getopt( spec, usage=TRUE ) ) ; - q( status = 1 ); -} - # Read inputs -merged <- read.table( opt$merged ) -read_counts <- read.table( opt$read_counts ) +merged <- read.table( args[1] ) +read_counts <- read.table( args[2] ) barcodes_nt <- merged[ do.call( paste, as.list( merged[ ,1:3 ] ) ) %in% do.call( paste, as.list( read_counts[ ( read_counts[ , 4 ] ) <= summary( read_counts[ , 4 ] )[ 5 ], 1:3 ] ) ) , 4 ] ##make the matrix with the nucleotide freqs per position: -nt_counts <- matrix( nrow = 4, ncol = opt$barcode_length ) +nt_counts <- matrix( nrow = 4, ncol = as.numeric(args[4]) ) for( h in 1:ncol( nt_counts ) ){ j <- 1 for( nt_local in c( "A","C","G","T" ) ) { @@ -59,7 +38,7 @@ i <- 1 results[ i ] <- sum( 1 - ( 1 - probs )**i ) -while( results[ i ] <= opt$max_observed ) { +while( results[ i ] <= as.numeric(args[3]) ) { i <- i + 1 results[ i ] <- sum( 1 - ( 1 - probs )**i ) #Mf to Sf } @@ -71,4 +50,4 @@ Uf_to_Mf[ i ] <- which( difference == min( difference ) ) #if you want to know how many molecules underlie n unique barcodes ask Uf_to_Mf[n] } -write( Uf_to_Mf, file = opt$output ) +write( Uf_to_Mf, file = args[5] ) diff -r 6b9e957d8db1 -r 2ae336f19de0 normalize.xml --- a/normalize.xml Tue Nov 04 15:11:36 2014 -0500 +++ b/normalize.xml Tue Nov 04 17:54:42 2014 -0500 @@ -1,5 +1,5 @@ - RNA probing data + RNA probing signal R_3_1_1 RNAprobR diff -r 6b9e957d8db1 -r 2ae336f19de0 summarize_unique_barcodes.sh --- a/summarize_unique_barcodes.sh Tue Nov 04 15:11:36 2014 -0500 +++ b/summarize_unique_barcodes.sh Tue Nov 04 17:54:42 2014 -0500 @@ -210,7 +210,7 @@ if [ "$k2n" == "True" ]; then bar_length=$(head -n 1 $barcodes | cut -f 2 | xargs expr length) - Rscript $R_SCRIPT_PATH/k2n.R -m merged_temp.gz -c $output_dir/read_counts.txt -b ${max_observed_barcodes} -l $bar_length -o $output_dir/k2n.txt + Rscript $R_SCRIPT_PATH/k2n.R merged_temp.gz $output_dir/read_counts.txt ${max_observed_barcodes} $bar_length $output_dir/k2n.txt fi #Remove temp files