immunomind / immunarch

🧬 Immunarch: an R Package for Fast and Painless Exploration of Single-cell and Bulk T-cell/Antibody Immune Repertoires
https://immunarch.com
Apache License 2.0
297 stars 65 forks source link

repDiversity -raref Error #147

Open AimSchina opened 3 years ago

AimSchina commented 3 years ago

Dear all, I am getting an error while using the repDiversity function with method set to raref, the issue is the same as https://github.com/immunomind/immunarch/issues/19, however I don't understand how to fix it . My data are processed after running MiXCR, and have tried in both downsampled and non-downsampled data. I have also created different objects for TCR alpha and TCR beta chain CDR3 sequences, the example given below is with TCR alpha.

I am using the 0.6.6 immunarch version.

Running as:

imm_raref <- repDiversity(my_data$data, "raref", .verbose = T,.norm=T,.step = 1)

and the error I get is:

Error in if (Sest[1] == Sobs) { : missing value where TRUE/FALSE needed

Here is a snapshot of how my data look like: image

I would appreciate any help/feedback on this! ps. I cannot provide test data, since those are not published yet.

Thank you! :)

Alexander230 commented 2 years ago

Hi, @AimSchina! My name is Aleksandr Popov, I am a developer of the Immunarch package. Thank you for using our software!

Unfortunately, we can't reproduce the bug using the dataset that comes with Immunarch. Could you provide a minimal reproducible example of your error with a small data sample? You can use this method to create a minimal reproducible example from your data: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

licmn commented 2 years ago

I'm getting the same error. AimSchina where you able to fix it?

Alexander230 commented 2 years ago

Hi, @licmn! My name is Aleksandr Popov, I am a developer of the Immunarch package.

I see you have the same bug. Could you, please, provide me a reproducible example of your error? Small data sample and used commands with their arguments would be great. It will help me to fix the error.

Good luck, Aleksandr

licmn commented 2 years ago

Thanks Aleksandr! This is the message I get after running the following line of code: imm_raref <- repDiversity(my_data$data, "raref", .verbose = F) # I get similar mistake if changed to TRUE

Rarefaction analysis --- NOT WORKING---

imm_raref <- repDiversity(all_immdata_mixcr$data, "raref", .verbose = F) Error in if (Sest[1] == Sobs) { : missing value where TRUE/FALSE needed

m-a-l-i-k commented 2 years ago

The same problem has just occurred to me. It seems like it is related to clones that have been observed less than twice. Anyway, when I filter them out, there is no error anymore.

Rarefaction analysis seems to be only indirectly affected. The problem seems to be primarily related to chao1.

I could try to construct a minimal data set in case you still need it to reproduce this error.

Thank you for providing immunarch and best wishes!

Alexander230 commented 2 years ago

Hi, @licmn and @m-a-l-i-k!

Thank you for reporting this issue! Unfortunately, I still have no data sample to reproduce it. I've made an experimental fix, please install immunarch from diversity-fix branch and check it with your data:

install.packages(c("devtools", "pkgload"))
devtools::install_github("immunomind/immunarch", ref="diversity-fix")
devtools::reload(pkgload::inst("immunarch"))

When the fix will be finalized, it will be moved to dev branch; after that, to install it, use ref="dev" instead of ref="diversity-fix" in these commands.

Best regards, Aleksandr