You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am processing large numbers of WES samples with facets and have observed the same error in a very small number of the samples namely an R error
Error in `$<-.data.frame`(`*tmp*`, "ocn", value = numeric(0)) :
replacement has 0 rows, data has XX
where XX is any number. I investigated by running the code chunk by chunk and the error is raised
at the line
out$ocn <- 2^(1 + out$cnlr.median - dipLogR)
of the internal function fitcnf0. For the problematic samples, dipLogR has value numeric(0) which R does not like at all in math operations. I traced the code back to where dipLogR is computed i.e in the function findDiploidLogR.
I include here the value of out0 before proceeding.
Because there is no segment among the segments above with a value of mafR below 0.025, the threshold is raised to 0.05. Only line 25 of out0 satisfies this condition and therefore bsegs takes the value 25. Also, ocnlevels takes the value
Continuing through the function, dipLogR takes the intermediate value 1.106909438 after running
} else {
¦ ¦ # make sure bsegs is not empty
¦ ¦ if (length(bsegs) == 0) {
¦ ¦ ¦ ¦ # if no balanced segs set dipLogR at the median of cnlr
¦ ¦ ¦ ¦ dipLogR <- median(cnlr)
¦ ¦ ¦ ¦ nbal <- 0
¦ ¦ } else {
¦ ¦ ¦ ¦ dipLogR <- cnlr.median[bsegs]
¦ ¦ ¦ ¦ nbal <- num.mark[bsegs]
¦ ¦ }
}
Advancing through the code, not1plus1 takes the value FALSE and therefore we arrive at where cn2logR is computed
# find deviance for each ocnlevel
# ocn levels cannot be any lower than lr4-1
ocnlevels0 <- ocnlevels[ocnlevels > dipLogR[1]-1 & ocnlevels < dipLogR[1]]
dev1 <- sapply(ocnlevels0, facets:::dlrdev, dipLogR[1], out1)
[...]
cn2logR <- ocnlevels0[which.min(dev1)]
The problem here is that there is not a single value in the vector ocnlevels that satisfies ocnlevels > dipLogR[1]-1 & ocnlevels < dipLogR[1] which makes ocnlevels0 (and subsequently cn2logR) take the value numeric(0).
However, changing the strictly inferior in ocnlevels[ocnlevels > dipLogR[1]-1 & ocnlevels < dipLogR[1]]
to less than or equal as follows ocnlevels[ocnlevels > dipLogR[1]-1 & ocnlevels <= dipLogR[1]]
makes ocnlevels0 take the length-1 vector value [1] 1.106909 and subsequently cn2LogR the value 1.106909, thereby avoiding the error I described at the beginning.
Is the strictly inferior needed in ocnlevels[ocnlevels > dipLogR[1]-1 & ocnlevels < dipLogR[1]] or is it ok to replace it by a simple less than or equal to? I know that we often use interchangeably < and <= with no consequence at all but here is an example where it makes a difference.
Best,
Yoann
The text was updated successfully, but these errors were encountered:
ypradat
changed the title
Error "replace has 0 rows", caused by dipLogR=numeric(0)
Error "replacement has 0 rows", caused by dipLogR=numeric(0)
Oct 17, 2022
ypradat
added a commit
to ypradat/facets
that referenced
this issue
Oct 17, 2022
I am sorry I can't find again the pileup matrix that led to the error I described above. I'll make sure to keep it in case I come across this error again. I thought that the table out0 I provided to you in my previous message would be enough for you to figure out what was going on.
Dear developer,
I am processing large numbers of WES samples with
facets
and have observed the same error in a very small number of the samples namely an R errorwhere XX is any number. I investigated by running the code chunk by chunk and the error is raised
at the line
of the internal function
fitcnf0
. For the problematic samples,dipLogR
has valuenumeric(0)
which R does not like at all in math operations. I traced the code back to wheredipLogR
is computed i.e in the functionfindDiploidLogR
.I include here the value of
out0
before proceeding.Because there is no segment among the segments above with a value of
mafR
below 0.025, the threshold is raised to 0.05. Only line 25 ofout0
satisfies this condition and thereforebsegs
takes the value25
. Also,ocnlevels
takes the valueafter running
Continuing through the function,
dipLogR
takes the intermediate value1.106909438
after runningAdvancing through the code,
not1plus1
takes the valueFALSE
and therefore we arrive at wherecn2logR
is computedThe problem here is that there is not a single value in the vector
ocnlevels
that satisfiesocnlevels > dipLogR[1]-1 & ocnlevels < dipLogR[1]
which makesocnlevels0
(and subsequentlycn2logR
) take the valuenumeric(0)
.However, changing the strictly inferior in
ocnlevels[ocnlevels > dipLogR[1]-1 & ocnlevels < dipLogR[1]]
to less than or equal as follows
ocnlevels[ocnlevels > dipLogR[1]-1 & ocnlevels <= dipLogR[1]]
makes
ocnlevels0
take the length-1 vector value[1] 1.106909
and subsequentlycn2LogR
the value1.106909
, thereby avoiding the error I described at the beginning.Is the strictly inferior needed in
ocnlevels[ocnlevels > dipLogR[1]-1 & ocnlevels < dipLogR[1]]
or is it ok to replace it by a simple less than or equal to? I know that we often use interchangeably<
and<=
with no consequence at all but here is an example where it makes a difference.Best,
Yoann
The text was updated successfully, but these errors were encountered: