Mercurial > repos > shians > shrnaseq
comparison hairpinTool.R @ 4:f8af57d6f60b
Fixed bug causing fastq input to break
- Moved misplaced error check causing fastq inputs to not function
author | shian_su <registertonysu@gmail.com> |
---|---|
date | Mon, 24 Feb 2014 14:41:39 +1100 |
parents | 076ca575208f |
children | 3d04308a99f9 |
comparison
equal
deleted
inserted
replaced
2:076ca575208f | 4:f8af57d6f60b |
---|---|
168 offenders <- unmake.names(offenders) | 168 offenders <- unmake.names(offenders) |
169 stop("ID column of sample annotation must have unique values, values ", | 169 stop("ID column of sample annotation must have unique values, values ", |
170 offenders, " are repeated") | 170 offenders, " are repeated") |
171 } # Check that IDs in sample annotation are unique | 171 } # Check that IDs in sample annotation are unique |
172 | 172 |
173 if (any(is.na(match(samples$ID, colnames(counts))))) { | |
174 stop("not all samples have groups specified") | |
175 } # Check that a group has be specifed for each sample | |
176 | |
177 if (inputType=="fastq") { | 173 if (inputType=="fastq") { |
178 | 174 |
179 if (any(table(hairpins$ID)>1)){ | 175 if (any(table(hairpins$ID)>1)){ |
180 tab <- table(hairpins$ID) | 176 tab <- table(hairpins$ID) |
181 offenders <- paste(names(tab[tab>1]), collapse=", ") | 177 offenders <- paste(names(tab[tab>1]), collapse=", ") |
182 stop("ID column of hairpin annotation must have unique values, values ", | 178 stop("ID column of hairpin annotation must have unique values, values ", |
183 offenders, " are repeated") | 179 offenders, " are repeated") |
184 } # Check that IDs in hairpin annotation are unique | 180 } # Check that IDs in hairpin annotation are unique |
185 | 181 |
186 } else if (inputType=="counts") { | 182 } else if (inputType=="counts") { |
183 if (any(is.na(match(samples$ID, colnames(counts))))) { | |
184 stop("not all samples have groups specified") | |
185 } # Check that a group has be specifed for each sample | |
187 | 186 |
188 if (any(table(counts$ID)>1)){ | 187 if (any(table(counts$ID)>1)){ |
189 tab <- table(counts$ID) | 188 tab <- table(counts$ID) |
190 offenders <- paste(names(tab[tab>1]), collapse=", ") | 189 offenders <- paste(names(tab[tab>1]), collapse=", ") |
191 stop("ID column of count table must have unique values, values ", | 190 stop("ID column of count table must have unique values, values ", |
291 hpReadout <- gsub(" -- ", "", hpReadout, fixed=TRUE) | 290 hpReadout <- gsub(" -- ", "", hpReadout, fixed=TRUE) |
292 | 291 |
293 | 292 |
294 # Make the names of groups syntactically valid (replace spaces with periods) | 293 # Make the names of groups syntactically valid (replace spaces with periods) |
295 data$samples$group <- make.names(data$samples$group) | 294 data$samples$group <- make.names(data$samples$group) |
296 } else { | 295 } else if (inputType=="counts") { |
297 # Process counts information, set ID column to be row names | 296 # Process counts information, set ID column to be row names |
298 rownames(counts) <- counts$ID | 297 rownames(counts) <- counts$ID |
299 counts <- counts[ , !(colnames(counts)=="ID")] | 298 counts <- counts[ , !(colnames(counts)=="ID")] |
300 countsRows <- nrow(counts) | 299 countsRows <- nrow(counts) |
301 | 300 |