Skip to content

Commit

Permalink
Still passing with _R_CHECK_LENGTH_1_LOGIC2_=FALSE, still failling wi…
Browse files Browse the repository at this point in the history
…th _R_CHECK_LENGTH_1_LOGIC2_=TRUE
  • Loading branch information
sneumann committed Feb 10, 2020
1 parent 9e95680 commit 34795a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
19 changes: 15 additions & 4 deletions R/fct_findIsotopes.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ findIsotopesPspec <- function(isomatrix, mz, ipeak, int, params){
}

## IM - isotope matrix (column diffs(min,max) per charge, row num. isotope)
## STN: isn't it rather:
## IM - isotope matrix (column diffs(min,max) per ISOTOPE, row num. charge state)
IM <- t(sapply(1:params$maxcharge,function(x){
mzmin <- (params$IM[, "mzmin"]) / x;
mzmax <- (params$IM[, "mzmax"]) / x;
Expand Down Expand Up @@ -85,11 +87,20 @@ findIsotopesPspec <- function(isomatrix, mz, ipeak, int, params){
for(iso in 1:min(params$maxiso,ncol(hits.iso))){
hit <- apply(hits.iso,1, function(x) any(CAMERA:::naOmit(x)==iso))
hit[which(is.na(hit))] <- TRUE
if(all(hit)) break;
if(all(hit))
break;
hits.iso[!hit,] <- t(apply(hits.iso[!hit,,drop=FALSE],1, function(x) {
if(!all(is.na(x))){
ini <- which(x > iso)
if(!is.infinite(ini) && length(ini) > 0){

## Here the following condition was previously:
## if(!is.infinite(ini) && length(ini) > 0){
##
## The fix for issue #44 assumes the follwoing:
## "There is at least one hit" Not sure why
## ini as return value of which() would contain inf at all

if(!is.infinite(ini)[1] & length(ini) > 0){
x[min(ini):ncol(hits.iso)] <- NA
}
}
Expand Down Expand Up @@ -213,8 +224,8 @@ findIsotopesPspec <- function(isomatrix, mz, ipeak, int, params){
break;
}
}
}#end for charge
}#end for j
}# for(charge in 1:nrow(candidate.matrix)){
}# end for ( j in 1:(length(mz) - 1)){

return(isomatrix)
}
Expand Down
2 changes: 1 addition & 1 deletion R/pspec2metfrag.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extractfragments <- function(object, pspecidx=NULL) {
sp <- getpspectra(object, grp=pspec)
rt <- median(sp[, "rt"])
peakID <- object@pspectra[[pspec]]
if(object@sample == 1 && length(sampnames(object@xcmsSet)) == 1){
if(object@sample == 1 & length(sampnames(object@xcmsSet)) == 1){
#single sample
#intIdx <- intVal;
intIdx <- "maxo";
Expand Down
8 changes: 4 additions & 4 deletions R/xsAnnotate.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ xsAnnotate <- function(xs=NULL, sample=NA, nSlaves=1, polarity=NULL){

object <- new("xsAnnotate");

if(length(sampnames(xs)) > 1 && !nrow(xs@groups) > 0) {
if(length(sampnames(xs)) > 1 & !nrow(xs@groups) > 0) {
# more than one sample
# checking alignment
stop ('First argument must be a xcmsSet with group information or contain only one sample.')
Expand All @@ -19,7 +19,7 @@ xsAnnotate <- function(xs=NULL, sample=NA, nSlaves=1, polarity=NULL){
if(length(sample) > 1){
#example sample <- c(1,2,3,4,5)

if(all(sample < length(xs@filepaths) && sample > 0)){
if(all(sample <= length(xs@filepaths)) & all(sample > 0)){
#all sample values are in allowed range
object@sample <- sample;
}else{
Expand Down Expand Up @@ -785,7 +785,7 @@ setMethod("findAdducts", "xsAnnotate", function(object, ppm=5, mzabs=0.015, mult
object@pspectra[[1]] <- seq(1:nrow(object@groupInfo));
}

if(object@sample == 1 && length(sampnames(object@xcmsSet)) == 1){
if(object@sample == 1 & length(sampnames(object@xcmsSet)) == 1){
##one sample case
mint <- object@groupInfo[, intval];
}else{
Expand Down Expand Up @@ -1266,7 +1266,7 @@ setMethod("getPeaklist", "xsAnnotate", function(object, intval="into") {

#generate peaktable
#Check if xcmsSet contains only one sample
if(object@sample == 1 && length(sampnames(object@xcmsSet)) == 1){
if(object@sample == 1 & length(sampnames(object@xcmsSet)) == 1){
#intval is here ignored since all intensity values are already contained
peaktable <- object@groupInfo;
}else {
Expand Down

0 comments on commit 34795a2

Please # to comment.