hadexversum / HaDeX

Analysis and Visualisation of Hydrogen/Deuterium Exchange Mass Spectrometry Data
http://mslab-ibb.pl/shiny/HaDeX/
8 stars 2 forks source link

Warnings generated by calculate_p_value #132

Closed DominikRafacz closed 2 years ago

DominikRafacz commented 2 years ago

Code in calculate_p_value generates enormous amount of warnings which state (pun intended):

Warning in st_1 == st_2 :
  longer object length is not a multiple of shorter object length

this happens from within this part of the code:

lapply(1:nrow(vol_dat), function(i){

    st_1 <- vol_dat[i, "masses_1"][[1]]
    st_2 <- vol_dat[i, "masses_2"][[1]]

    if(length(st_1) == 1 | all(st_1 == st_2)) {
      p_value <- NA
    } else if (length(st_2) == 1){
      p_value <- NA
    } else {
      p_value <- t.test(x = st_1, y = st_2, paired = FALSE, alternative = "two.sided", conf.level = confidence_level)$p.value
    }

    ...
})

It happens really often that number of records for different states is unequal. I assume that in that case the problematic if statement should also return FALSE. Currently, since vectors of different length are compared in this manner, shorter one is recycled, so it is theoretically possible that this expression will be evaluated to TRUE for vectors of different length.