Mercurial > repos > davidecangelosi > pipe_t
comparison pipe-t.R @ 2:6cd22b1fbf6d draft
planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
author | davidecangelosi |
---|---|
date | Mon, 06 May 2019 05:37:40 -0400 |
parents | 185ba61836ab |
children | e2fcf5a4609c |
comparison
equal
deleted
inserted
replaced
1:ecd0a79e8130 | 2:6cd22b1fbf6d |
---|---|
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
141 cat("\n Initialization completed! \n") | 141 cat("\n Initialization completed! \n") |
142 | 142 |
143 .readCtEDS <- | |
144 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...) | |
145 { | |
146 # Scan through beginning of file, max 100 lines | |
147 file.header <- readLines(con=readfile, n=100) | |
148 n.header <- grep("^Well", file.header) | |
149 if (length(n.header)==0) | |
150 n.header <- 0 | |
151 # Read data, skip the required lines | |
152 out <- read.delim(file=readfile, header=TRUE, colClasses="character", nrows=nspots*n.data[i], skip=n.header-1, strip.white=TRUE, ...) | |
153 out | |
154 } # .readCtEDS | |
155 | |
156 | |
157 .readCtPlain <- | |
158 function(readfile=readfile, header=header, n.features=n.features, n.data=n.data, i=i, ...) | |
159 { | |
160 # A check for file dimensions. Read a single file. | |
161 sample <- read.delim(file=readfile, header=header, ...) | |
162 nspots <- nrow(sample) | |
163 if (nspots != n.features*n.data[1]) | |
164 warning(paste(n.features, "gene names (rows) expected, got", nspots)) | |
165 # Read in the required file | |
166 out <- read.delim(file=readfile, header=header, colClasses="character", nrows=nspots*n.data[i], ...) | |
167 # Return | |
168 out | |
169 } # .readCtPlain | |
170 | |
171 .readCtSDS <- | |
172 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...) | |
173 { | |
174 # Scan through beginning of file, max 100 lines | |
175 file.header <- readLines(con=readfile, n=100) | |
176 n.header <- grep("^#", file.header) | |
177 if (length(n.header)==0) | |
178 n.header <- 0 | |
179 # Read data, skip the required lines | |
180 out <- read.delim(file=readfile, header=FALSE, colClasses="character", nrows=nspots*n.data[i], skip=n.header, strip.white=TRUE, ...) | |
181 # Return | |
182 out | |
183 } # .readCtSDS | |
184 | |
185 .readCtLightCycler <- | |
186 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...) | |
187 { | |
188 # Read data, skip the required lines | |
189 out <- read.delim(file=readfile, header=TRUE, as.is=TRUE, nrows=nspots*n.data[i], skip=1, strip.white=TRUE, ...) | |
190 # Return | |
191 out | |
192 } # .readCtLightCycler | |
193 | |
194 .readCtCFX <- function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...) | |
195 { | |
196 # Read data, skip the required lines | |
197 out <- read.csv(file=readfile, header=TRUE, as.is=TRUE, nrows=nspots*n.data[i], strip.white=TRUE, ...) | |
198 # Return | |
199 out | |
200 } # .readCtCFX | |
201 | |
202 .readCtOpenArray <- | |
203 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...) | |
204 { | |
205 # Read data | |
206 out <- read.csv(file=readfile, header=TRUE, as.is=TRUE, nrows=nspots*n.data[i], strip.white=TRUE, ...) | |
207 # Regard those marked as outliers as "Unreliable" | |
208 out$ThroughHole.Outlier[out$ThroughHole.Outlier=="False"] <- "OK" | |
209 out$ThroughHole.Outlier[out$ThroughHole.Outlier=="True"] <- "Unreliable" | |
210 # Return | |
211 out | |
212 } # .readCtOpenArray | |
213 | |
214 .readCtBioMark <- | |
215 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...) | |
216 { | |
217 # Scan through beginning of file, max 100 lines | |
218 file.header <- readLines(con=readfile, n=100) | |
219 n.header <- grep("^ID", file.header)-1 | |
220 if (length(n.header)==0) | |
221 n.header <- 0 | |
222 # Read data, skip the required lines | |
223 out <- read.csv(file=readfile, header=TRUE, as.is=TRUE, nrows=nspots*n.data[i], skip=n.header, strip.white=TRUE, ...) | |
224 # Convert the calls into flags | |
225 out$Call[out$Call=="Pass"] <- "OK" | |
226 out$Call[out$Call=="Fail"] <- "Undetermined" | |
227 # Return | |
228 out | |
229 } # .readCtBioMark | |
230 | |
231 | |
232 | |
143 readCtDataDav<- | 233 readCtDataDav<- |
144 function (files, path = NULL, n.features = 384, format = "plain", | 234 function (files, path = NULL, n.features = 384, format = "plain", |
145 column.info, flag, feature, type, position, Ct, header = FALSE, | 235 column.info, flag, feature, type, position, Ct, header = FALSE, |
146 SDS = FALSE, n.data = 1, samples, na.value = 40, sample.info, | 236 SDS = FALSE, n.data = 1, samples, na.value = 40, sample.info, |
147 ...) | 237 ...) |
281 out <- new("qPCRset", exprs = X, phenoData = sample.info, | 371 out <- new("qPCRset", exprs = X, phenoData = sample.info, |
282 featureData = featData, featureCategory = X.cat, flag = X.flags, | 372 featureData = featData, featureCategory = X.cat, flag = X.flags, |
283 CtHistory = X.hist) | 373 CtHistory = X.hist) |
284 out | 374 out |
285 } | 375 } |
286 .readCtEDS <- | 376 |
287 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...) | |
288 { | |
289 # Scan through beginning of file, max 100 lines | |
290 file.header <- readLines(con=readfile, n=100) | |
291 n.header <- grep("^Well", file.header) | |
292 if (length(n.header)==0) | |
293 n.header <- 0 | |
294 # Read data, skip the required lines | |
295 out <- read.delim(file=readfile, header=TRUE, colClasses="character", nrows=nspots*n.data[i], skip=n.header-1, strip.white=TRUE, ...) | |
296 out | |
297 } # .readCtEDS | |
298 | 377 |
299 head(read.delim(file.path(path000, dpfiles), sep="\t")) | 378 head(read.delim(file.path(path000, dpfiles), sep="\t")) |
300 files <- read.delim(file.path(path000, dpfiles), sep="\t") | 379 files <- read.delim(file.path(path000, dpfiles), sep="\t") |
301 switch(format, | 380 switch(format, |
302 "EDS"={ | 381 "EDS"={ |
540 setCtHistory(q) <- data.frame(history="Manually created qPCRset object.", stringsAsFactors=FALSE) | 619 setCtHistory(q) <- data.frame(history="Manually created qPCRset object.", stringsAsFactors=FALSE) |
541 setCtHistory(q) <- rbind(getCtHistory(q), capture.output(match.call(normalizeCtData))) | 620 setCtHistory(q) <- rbind(getCtHistory(q), capture.output(match.call(normalizeCtData))) |
542 # Return the normalised object | 621 # Return the normalised object |
543 q | 622 q |
544 } | 623 } |
545 | 624 #library(NormqPCR) |
625 | |
626 #delete.na <- function(DF, n=0) { | |
627 # DF[rowSums(is.na(DF)) <= n,] | |
628 #} | |
629 | |
630 #user_number=5 | |
631 #genorm <- selectHKs(t(delete.na(as.matrix(exprs(xGlico)),0)), method = "geNorm", Symbols = rownames(as.matrix(delete.na(exprs(xGlico),0))), minNrHK = as.numeric(user_number), log = TRUE) | |
632 #normfinder <- selectHKs(as.matrix(t(delete.na(exprs(xGlico),0))), group= files$Treatment , method = "NormFinder", Symbols =rownames(as.matrix(delete.na(exprs(xGlico),0))), minNrHK = as.numeric(user_number), log = TRUE) | |
633 #intersection= intersect(normfinder$ranking, genorm$ranking[1:as.numeric(user_number)]) | |
634 | |
635 #cat("\n GeNorm and NormFinder transcripts selected as housekeeping for normalization! \n") | |
636 #intersection | |
637 #dnorm <- normalizeCtData(xGlico , norm="deltaCt", deltaCt.genes=as.vector(intersection)) | |
546 | 638 |
547 switch(normalizationMethod, | 639 switch(normalizationMethod, |
548 "deltaCt"={ | 640 "deltaCt"={ |
549 normalizedDataset <- normalizeCtDataDav(xFilter, norm="deltaCt", deltaCt.genes =explode(normalizers, sep = ",")) | 641 normalizedDataset <- normalizeCtDataDav(xFilter, norm="deltaCt", deltaCt.genes =explode(normalizers, sep = ",")) |
550 }, | 642 }, |