Error resampling loci

54 views
Skip to first unread message

Juan Enciso

unread,
Jan 17, 2025, 4:04:30 PMJan 17
to dartR
Dear dartR authors,

I am working with a ddRAD dataset and I am trying to subsample loci using the gl.subsample.loc function as follows:

test_subsample <- gl.subsample.loc(gl_scheme_81, nLoc(gl_scheme_81),
                                   replace = TRUE, error.check = TRUE)

After subsampling I filter monomorhps and recalculate metrics, which produces an error when calculating the minor allele frequency

gl.recalc.metrics(gl.filter.monomorphs(test_subsample), verbose = 5)

Completed: utils.recalc.freqhomsnp Recalculating Minor Allele Frequency (MAF) Error in `$<-.data.frame`(`*tmp*`, "frequency", value = c(`17864:0:+` = 0.236245954692557, : replacement has 14591 rows, data has 9203

Can you guide me on tackling this error?

Best regards,

Juan Enciso

Arthur Georges

unread,
Jan 17, 2025, 7:31:50 PMJan 17
to da...@googlegroups.com
Hi Juan,

Can you run gl <- gl.compliance.check(gl), try again and get back to me.

We have not fully got on top of all the nuances to do with data not generated by DArT Pty Ltd. Could be something to do with this.

Ta

Arthur



--
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/46bcd81e-ffa1-4a8b-962b-2d1741330fe2n%40googlegroups.com.

Juan Enciso

unread,
Jan 20, 2025, 9:49:05 AMJan 20
to dartR
Hi Arthur,

When running gl.compliance.check I am getting the same error.

gl.compliance.check(gl.filter.monomorphs(test_subsample), verbose = 5)


Error in `$<-.data.frame`(`*tmp*`, "frequency", value = c(`17864:0:+` = 0.236245954692557, : replacement has 14591 rows, data has 9203

No other detail
s are given in the message. Is it helpful if I upload my data?

Best,

Juan

Juan Enciso

unread,
Jan 20, 2025, 10:32:21 AMJan 20
to da...@googlegroups.com
Dear Arthur,

As a follow up, I have tried the same with the platypus data that comes with dartR and I encountered the same problem.

test_platypus_ss <- gl.subsample.loc(platypus.gl, nLoc(platypus.gl),

                                     replace = TRUE, error.check = TRUE)

gl.compliance.check(test_platypus_ss, verbose = 5)

Error in `$<-.data.frame`(`*tmp*`, "frequency", value = c(`45068381-56-A/G` = 0.480263157894737,  :
  replacement has 1000 rows, data has 632

Bernd.Gruber

unread,
Jan 20, 2025, 11:46:11 PMJan 20
to da...@googlegroups.com

Hi Juan,

 

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

 

# install developing version of dartR.base

# NOTE that in the below line you have to replace "_at_" by "@"

devtools::install_github("green-striped-gecko/dartR.base_at_dev")

 

# OR

 

dartRverse::dartRverse_install(

  package = "dartR.base",

  rep = "Github",

  branch = "dev",

  verbose = TRUE

)

library(dartRverse)

x <- platypus.gl

test_platypus_ss <- gl.subsample.loc(x,

                                     n = nLoc(x),

                                     replace = TRUE,

                                     error.check = TRUE)

test_platypus_ss <- gl.compliance.check(test_platypus_ss, verbose = 5)

 

Cheers,

Luis

Message has been deleted

Romney Francis

unread,
Jul 18, 2025, 7:48:52 PMJul 18
to dartR
Hi DartR team,

I'm having a similar issue with the sexlinked package and have tried the above solution with no success. I'm using DArT SNP data to examine genetic structuring and sex-biased dispersal in red-tailed tropicbirds. I also attended the ICCB 2025 workshop, and Diana stressed the importance of dropping sex-linked loci when filtering. I have known sexes for all my individuals and have successfully dropped the sex-linked loci, but when I try to filter for loci callrate afterwards, I get this error (example using EYR dataset): 

EYRgl <- gl.drop.sexlinked(EYR, system = "zw")
gl.report.callrate(EYRgl, method = "loc")
Error in `$<-.data.frame`(`*tmp*`, "CallRate", value = c(`8897157-24-G/T` = 0.872122762148338, : replacement has 850 rows, data has 1000

I made sure that all the dartR packages are the up-to-date dev versions. I've also tried gl.compliance.check and gl.recalc.metrics and have had the same error.
Any insight into this would be much appreciated!

Thanks,
Romney Edwards-Francis
Message has been deleted

nanisrobledo

unread,
Aug 5, 2025, 7:24:21 PMAug 5
to dartR
Hi Romney,

Thanks for reaching out. I tried running the code you sent using the EYR dataset and I could not reproduce the error you got. That means that it may have to do with some incompatibility with old/new dartR versions. My guess is that maybe you still have dartR installed (as well as dartRverse packages). Is that correct? Can you try uninstalling dartR, please? What I mean by that is that some time ago the package was called dartR, but now it is dartRverse, which means that you would have installed individual dartRverse packages: dartR.base, dartR.data, dartR.sexlinked. Please only uninstall dartR.

Let me know how that goes!
Diana
Reply all
Reply to author
Forward
0 new messages