Skip to content
Snippets Groups Projects
Commit 89aa66b3 authored by Thomas  OBADIA's avatar Thomas OBADIA
Browse files

Fix the same issue as in preceding commits (hardcoded row numbers with respect...

Fix the same issue as in preceding commits (hardcoded row numbers with respect to median / count data) but for CSV inputs.
parent 6ac82225
No related branches found
No related tags found
No related merge requests found
......@@ -61,21 +61,33 @@ runRelativeAntibodyUnits = function(fname1, fname2, MFI_CSV, MFI_N_ANTIGENS, TEM
if(MFI_CSV){
# Updated reading
L <- data.frame(read.csv(fname1,
header=T,
stringsAsFactors=FALSE,
colClasses=c(rep("character",3+as.integer(MFI_N_ANTIGENS))),
na.string=c("")))
L_full <- data.frame(read.csv(fname1,
header=T,
stringsAsFactors=FALSE,
colClasses=c(rep("character",3+as.integer(MFI_N_ANTIGENS))),
na.string=c("")))
# Identify first row
ROW_N = match("Location", L[,1])
# Identify rows
median_row_number <- which(L_full[,2] == "Median")
count_row_number <- which(L_full[,2] == "Count")
endcount_row_number <- which(L_full[,2] == "Avg Net MFI")
# Select data
L = L[ROW_N:(ROW_N+96),1:(3+as.integer(MFI_N_ANTIGENS))]
L = L_full[(median_row_number+1):nrow(L_full),1:(3+as.integer(MFI_N_ANTIGENS))]
# the first row will be the header
colnames(L) = L[1, ]
# removing the first row.
L = L[-1, ]
## Find all blank rows (i.e. rows that are all NA).
## Then keep rows preceding the first blank row.
blank.row.number <- which(rowSums(is.na(L)) == length(names(L)))[1]
if(is.na(blank.row.number)){
L = L
}else{
L <- L[1:(blank.row.number-1),]
}
## Exclude column that corresponds to "Total events"
L <- L[, !(colnames(L) %in% c("Total Events","TotalEvents"))]
......@@ -92,16 +104,7 @@ runRelativeAntibodyUnits = function(fname1, fname2, MFI_CSV, MFI_N_ANTIGENS, TEM
L[,-which(colnames(L) %in% c("Location","Sample","Total Events","TotalEvents"))] = lapply(L[,-which(colnames(L) %in% c("Location","Sample","Total Events"))], as.numeric)
## Load the counts to check for run quality control
C <- data.frame(read.csv(fname1,
header=T,
stringsAsFactors=FALSE,
colClasses=c(rep("character",3+as.integer(MFI_N_ANTIGENS))),
na.string=c("")))
# Row
ROW_C = 239
# Select data
C = C[ROW_C:(ROW_C+nrow(L)),1:(3+as.integer(MFI_N_ANTIGENS))]
C = L_full[(count_row_number+1):(count_row_number+1+nrow(L)),1:(3+as.integer(MFI_N_ANTIGENS))]
# the first row will be the header
colnames(C) = C[1, ]
# removing the first row.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment