The fragment that filters by quantile does not seem to do anything. q[1] is the lower quantile, q[2] is the upper quantile of x, thus x < q[1] & x > q[2]] is always FALSE. This means that x gets length of 0, and the entire expression:
apply(mat, 1, function(x) {
q = quantile(x, c(0.1, 0.9))
x = x[x < q[1] & x > q[2]]
var(x)/mean(x)
})
returns a named vector with "NA" only. In consequence ind is equivalent to 1:n.
What was meant probably was x = x[x > q[1] & x < q[2]], but if the example works without this step, it could just be removed.
If we correct the direction to align with the likely intent:
In https://jokergoo.github.io/ComplexHeatmap-reference/book/more-examples.html#visualize-cell-heterogeneity-from-single-cell-rnaseq in the function
get_correlated_variable_genes
:The fragment that filters by quantile does not seem to do anything.
q[1]
is the lower quantile,q[2]
is the upper quantile ofx
, thusx < q[1] & x > q[2]]
is alwaysFALSE
. This means thatx
gets length of 0, and the entire expression:returns a named vector with "NA" only. In consequence
ind
is equivalent to1:n
.What was meant probably was
x = x[x > q[1] & x < q[2]]
, but if the example works without this step, it could just be removed.If we correct the direction to align with the likely intent:
After removing the filtering code: