Error when bootstrapping heterozygosity estimates across loci

109 views
Skip to first unread message

Juan Enciso

unread,
Jan 30, 2025, 2:00:09 PMJan 30
to dartR
Hi dartR team,

I am trying to get CIs on heterozygosity estimates for my data bootstrapping across loci as follows.

hets_report_scheme_81_Loc <- gl.report.heterozygosity(gl_scheme_81, error.bar="CI",
                                                      nboots=10000, ncpus = 24,
                                                      CI.type="perc",
                                                      boot.method = "loc")

I am getting the following error:

Error in if (const(t, min(1e-08, mean(t, na.rm = TRUE)/1e+06))) { :
  missing value where TRUE/FALSE needed

Can you please help me figuring out what is wrong here?

Best,

Juan

Bernd.Gruber

unread,
Jan 30, 2025, 6:56:27 PMJan 30
to da...@googlegroups.com

Hi Juan,

 

Just looking at the error, is it possible you have loci with lots of missing data and the bootstrap creates a sample that has only missing data.

 

So maybe can you filter

 

gl.filter.callrate(gl, method=”loc”, thresh=0.99) or so and see if the error disappears…

 

cheers, Bernd

--
You received this message because you are subscribed to the Google Groups "dartR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dartr+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dartr/65a5e5a6-43e6-4e10-88a9-166226f1fe5cn%40googlegroups.com.

Message has been deleted

Juan Enciso

unread,
Jan 31, 2025, 6:14:13 PMJan 31
to dartR
Hi Bernd,

My data originally includes SNPs with up to 50% missing rate. I find 1% and 5% missing rates too stringent for my data leaving only 40 and 225 SNPs respectively. These produce an error that seems to be related to low content of data in the dataset.

When I set a threshold of 0.8 the error still persists. Would that still be a high amount of missing data? Also, even with a high percentage of missing data per site, is it possible to create situations of only missing data if the sampling is done across loci?

Best,

Juan



Jose Luis Mijangos

unread,
Feb 2, 2025, 6:26:08 PMFeb 2
to dartR

Hi Juan,

I ran the dataset you sent me without any issues.

Could you please install the developing version of dartR.base by running the commands below and then try again?

devtools::install_github("green-striped-gecko/dartR.base@dev")
library(dartRverse)
gl_scheme_81 <- readRDS("test.rds")
hets_report_scheme_81_Loc <- gl.report.heterozygosity(gl_scheme_81, error.bar = "CI", nboots = 10000, ncpus = 24, CI.type = "perc", boot.method = "loc" )

As you may know, we are no longer maintaining dartR and have transitioned to dartRverse (more details in the link below).

https://github.com/green-striped-gecko/dartRverse 

Sometimes, installing a new version can be a bit tricky. Here are a couple of points to help avoid common issues:

RStudio Auto-Loading dartRverse packages:

When you open RStudio, it may automatically load dartRverse packages if a genlight object exists in your environment. This can interfere with the update and cause the installation to fail.

Solution:

1. Clear your environment (Menu > Session > Clear Workspace) and then install the updated version of the dartRverse package of interest. Note that cleaning your environment will remove all existing variables and objects.

2. Alternatively, create a new RStudio project and install the updated version there.

Conflict with genlight Objects Created by dartR:

If your genlight object was created using dartR, RStudio may automatically load dartR (instead of dartRverse) when you open your session. This means that functions you run might come from dartR rather than dartRverse.

To resolve this issue, you can choose one of the following approaches:

1. Read your input file using dartRverse functions:

Clear your workspace, restart R, load dartRverse, and then use one of its dedicated functions (e.g., gl.read.csv, gl.read.dart, gl.read.fasta, gl.read.PLINK, gl.read.silicodart, or gl.read.vcf) to import your data.

2. Change the class of your genlight object:

If you prefer to convert your existing genlight object, you can change its class to be compatible with dartRverse. Below is an example of how to do this:

library(dartRverse)
# genlight object created using dartR
t1 <- your_genllight
# Assign the class "dartR" to the genlight object
class(t1) <- "dartR"
# Save the modified "dartR" object
gl.save(t1, "test2.rds")
# Now, to use it with dartRverse:
# 1. Clean your workspace: Menu > Session > Clear Workspace
# 2. Restart R: Menu > Session > Restart R
# 3. Load dartRverse
library(dartRverse)
# Load the converted dartR object
t2 <- gl.load("test2.rds")

Cheers,
Luis

Juan Enciso

unread,
Feb 5, 2025, 9:55:27 AMFeb 5
to dartR
Hi Luis,

Thank you for your response. I think I have the latest dartR.base version installed from github but just to verify, is it dartR.base v 1.0.0?

Jose Luis Mijangos

unread,
Feb 10, 2025, 3:13:51 AMFeb 10
to dartR
Hi Juan, 

Thank you for reporting this bug. The fix is available in the developing version of dartR.base which you can install as shown below:

devtools::install_github("green-striped-gecko/dartR.base@dev") 

Cheers,
Luis 

Juan Enciso

unread,
Feb 10, 2025, 3:17:35 PMFeb 10
to dartR
Hi Luis,

Thank you for this fix. I can confirm it is working well now. 

I have a follow-up question. I see that there is now a gl.report.allelerich function in dartR.base. Is there any chance that we can generate bootstrap confidence intervals for estimates of allelic richness in the same way that we do with gl.report.heterozygosity?

Best regards,

Juan

Comlan Arnaud Gouda

unread,
Mar 14, 2025, 1:42:43 AMMar 14
to da...@googlegroups.com

The first thing you need is to get the best results from your doctor or the best friend of the year and


Reply all
Reply to author
Forward
0 new messages