Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NA values in mean of ranked table #147

Open
mpaya opened this issue Jan 4, 2024 · 1 comment
Open

NA values in mean of ranked table #147

mpaya opened this issue Jan 4, 2024 · 1 comment

Comments

@mpaya
Copy link

mpaya commented Jan 4, 2024

When computing the step of bcRanks() to obtain the ranked table, all mean values were NA. In script Ranks.R, line 148, the mean() function uses na.omit = TRUE instead of na.rm = TRUE as in following statistical functions. With this modification, the issue is solved.

@katimbach
Copy link

It seems like something similar is happening with NaN values breaking bc4Squares:

> bc4Squares(bc, idents = "bc_clusters_res.0.2", lvl = "4")
Error in quantile.default(as.numeric(res$residuals.mean), prob = seq(from = 0,  : 
  missing values and NaN's not allowed if 'na.rm' is FALSE

In line 950 of Visualization.R, na.rm =TRUE, so not sure how to fix this one. Manually plugging this line seems to work fine:

> ranks<- as.data.frame(bc@ranks)
> quantile(as.numeric(ranks$bc_clusters_res.0.2.residuals.mean.0), na.rm = TRUE,
                            prob = seq(from = 0, to = 1, length = 11))
    0%    10%    20%    30%    40%    50%    60%    70%    80%    90%   100% 
-5.000 -1.151 -0.660 -0.383 -0.210 -0.095  0.050  0.233  0.452  0.904  9.850 
> quantile(as.numeric(ranks$bc_clusters_res.0.2.residuals.mean.1), na.rm = TRUE,
                            prob = seq(from = 0, to = 1, length = 11))
    0%    10%    20%    30%    40%    50%    60%    70%    80%    90%   100% 
-4.390 -1.886 -1.176 -0.750 -0.432 -0.070  0.310  0.620  1.102  1.720  4.590 
> quantile(as.numeric(ranks$bc_clusters_res.0.2.residuals.mean.2), na.rm = TRUE,
                            prob = seq(from = 0, to = 1, length = 11))
    0%    10%    20%    30%    40%    50%    60%    70%    80%    90%   100% 
-6.390 -2.576 -1.940 -1.352 -0.874 -0.390  0.080  0.640  1.740  2.302  6.460 
> quantile(as.numeric(ranks$bc_clusters_res.0.2.residuals.mean.3), na.rm = TRUE,
                            prob = seq(from = 0, to = 1, length = 11))
    0%    10%    20%    30%    40%    50%    60%    70%    80%    90%   100% 
-2.230 -0.901 -0.632 -0.410 -0.230 -0.050  0.090  0.263  0.492  0.790  2.500 
> quantile(as.numeric(ranks$bc_clusters_res.0.2.residuals.mean.4), na.rm = TRUE,
                            prob = seq(from = 0, to = 1, length = 11))
     0%     10%     20%     30%     40%     50%     60%     70%     80%     90% 
-24.890  -3.524  -2.100  -0.956   0.044   0.890   1.600   2.420   3.394   5.110 
   100% 
 13.380 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants