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

batch_sil with non-numeric batch codes #76

Open
jesswhitts opened this issue Apr 13, 2023 · 1 comment
Open

batch_sil with non-numeric batch codes #76

jesswhitts opened this issue Apr 13, 2023 · 1 comment

Comments

@jesswhitts
Copy link

Hello,

I get the following error when running batch_sil:

R[write to console]: Error in if (!all(x == round(x))) stop("'x' must only have integer codes") :
missing value where TRUE/FALSE needed

R[write to console]: In addition:
R[write to console]: Warning message:

R[write to console]: In silhouette(as.numeric(batch), dd) :
R[write to console]: NAs introduced by coercion

The problem comes from having non-numeric batch codes, which this line of code converts to NAs:
summary(silhouette(as.numeric(batch), dd))

Can you suggest any workaround for this?

Many thanks,
Jess

@mbuttner
Copy link
Collaborator

Hi @jesswhitts
thanks for pointing this out! A quick fix would be converting all batch codes to numeric values. If your batch covariate is a factor, you can usually convert the values of a factor to numeric with as.numeric(batch), as shown in the code. You can check if using a factor fixed the problem. I cannot reproduce the error, so it would be helpful to have a little example along with your R version.
Thanks!

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