philipmorrisintl / NPA

Network Perturbation Amplitude
Other
7 stars 1 forks source link

`computNPA` fails when the input data.frames don't have the same number of rows #3

Open MahShaaban opened 3 years ago

MahShaaban commented 3 years ago

computNPA fails with an uninformative error when the number of rows in the data.frames of the input list dL is not the same.

# Load packages
library(NPA)
#> Loading required package: R6
library(NPAModels)

# Load COPD data
data(COPD1)

# Load apoptosis model
net.apopto <- load_model('Mm', 'CFA', 'Apoptosis')

# Score the apoptosis model
npa <- compute_npa(COPD1, net.apopto, verbose = TRUE)
#> Preparing data...
#> Computing differential backbone values...
#> Computing amplitudes of perturbation...
#> Computing variance...
#> Computing downstream reshuffling...
#> Computing backbone reshuffling...
#> Done.

# COPD contain missing values
COPD2 <- COPD1
COPD2$`CS (5m)` <- COPD2$`CS (5m)`[-1,]

compute_npa(COPD2, net.apopto, verbose = TRUE)
#> Preparing data...
#> Error in sapply(dL, function(G) {: non-numeric argument to binary operator

Created on 2021-01-22 by the reprex package (v0.3.0)

The function checks the order of nodeLabel, but doesn't fail, here. Rather it fails when computing s, here

sgubianpm commented 3 years ago

@MahShaaban, this is correct. I will add some check of the rows of the different slots. Actually, they have to be the same across the slots, so if different, the intersection has to be used.

MahShaaban commented 3 years ago

Thanks @sgubianpm Yes. To get the function to work, I used the intersection of the slots as you point out. It would be great if the function can do that automatically, possibly with a warning. Or, the function could fail with an informative error message.