comparison normalize.r @ 2:f3fe0f64fe91 draft

Uploaded
author ynewton
date Mon, 17 Dec 2012 15:25:38 -0500
parents 8389b0c211ae
children
comparison
equal deleted inserted replaced
1:8389b0c211ae 2:f3fe0f64fe91
1 #!/usr/bin/Rscript 1 #!/usr/bin/Rscript
2
3 #Yulia Newton, last updated 20121217 v.3
2 4
3 #usage, options and doc goes here 5 #usage, options and doc goes here
4 argspec <- c("normalize.r - takes any flat file and normalizes the rows or the columns using various normalizations (median_shift, mean_shift, t_statistic (z-score), exp_fit, normal_fit, weibull_0.5_fit, weibull_1_fit, weibull_1.5_fit, weibull_5_fit). Requires a single header line and a single cloumn of annotation. 6 argspec <- c("normalize.r - takes any flat file and normalizes the rows or the columns using various normalizations (median_shift, mean_shift, t_statistic (z-score), exp_fit, normal_fit, weibull_0.5_fit, weibull_1_fit, weibull_1.5_fit, weibull_5_fit). Requires a single header line and a single cloumn of annotation.
5 Usage: 7 Usage:
6 normalize.r input.tab norm_type norm_by > output.tab 8 normalize.r input.tab norm_type norm_by > output.tab
214 normals_numeric <- normals[2:length(normals[,1]),2:length(normals[1,])] 216 normals_numeric <- normals[2:length(normals[,1]),2:length(normals[1,])]
215 normals_numeric <- apply(normals_numeric, 2, as.numeric) 217 normals_numeric <- apply(normals_numeric, 2, as.numeric)
216 rownames(normals_numeric) <- normals[,1][2:length(normals[,1])] 218 rownames(normals_numeric) <- normals[,1][2:length(normals[,1])]
217 colnames(normals_numeric) <- normals[1,][2:length(normals[1,])] 219 colnames(normals_numeric) <- normals[1,][2:length(normals[1,])]
218 220
221 #select only the intersection of the rows between the two matrices:
222 normals_numeric <- normals_numeric[rownames(normals_numeric) %in% rownames(data_matrix),]
223 data_matrix <- data_matrix[rownames(data_matrix) %in% rownames(normals_numeric),]
224 normals_numeric <- normals_numeric[order(rownames(normals_numeric)),]
225 data_matrix <- data_matrix[order(rownames(data_matrix)),]
226
219 combined_matrix <- cbind(data_matrix, normals_numeric) 227 combined_matrix <- cbind(data_matrix, normals_numeric)
220 tumor_indices <- c(1:length(data_matrix[1,])) 228 tumor_indices <- c(1:length(data_matrix[1,]))
221 normals_indices <- c(length(tumor_indices)+1:length(normals_numeric[1,])) 229 normals_indices <- c(length(tumor_indices)+1:length(normals_numeric[1,]))
222 data_matrix <- combined_matrix 230 data_matrix <- combined_matrix
223 } 231 }