Error running dartR::gl.filter.reproducibility

227 views
Skip to first unread message

Adam Marques

unread,
Feb 10, 2022, 7:20:59 AM2/10/22
to dartR
Hello,
I'm updating some old scripts used a few years ago. However, I appear to be having some issue with with dartR::gl.filter.reproducibility function and I suspect the associated dartR::gl2fasta function. Previously, this step was run with dartR::gl.filter.repavg.
I've tried executing the function with the training data without success.

dartR::testset.gl %>%
    dartR::gl.filter.reproducibility()
Starting Error in cat("Starting", funname, "\n") :
  argument 2 (type 'language') cannot be handled by 'cat'

Any suggestions for what might be causing the error would be much appreciated. I've recently updated to R version 4.1.0 (2021-05-18).

Regards,
Adam

Arthur Georges

unread,
Feb 10, 2022, 3:22:47 PM2/10/22
to da...@googlegroups.com
Hi Adam,

Sorry for not maintaining backward compatibility. We changed the script to gl.filter.reproducibility when we added in the functionality of dealing with SilicoDArT (fragment presence-absence) data. repAvg only applies to SNP data.

Not sure what is happening there because

test <- gl.report.reproducibility(testset.gl)
test <- gl.filter.reproducibility(testset.gl)

work fine for me.

Not sure what package is required for

dartR::testset.gl %>% dartR::gl.filter.reproducibility()

Is that a tidyverse thing?

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 on the web visit https://groups.google.com/d/msgid/dartr/60bb4e8f-6231-46cb-8879-7ef6e8f99de3n%40googlegroups.com.

Adam Marques

unread,
Feb 11, 2022, 5:05:41 AM2/11/22
to dartR
Hello Arthur,

I don't think the issue is with tidyverse, but just to be sure I ran it again without. I also tried updating all existing packages, and reinstalling dartR to see if that would resolve the issue. Unfortunately, I am still having the same issue, but since updating I did get a little bit of additional information in the error report.

dartR::gl.filter.reproducibility(dartR::testset.gl)
Registered S3 method overwritten by 'pegas':
  method      from
  print.amova ade4
Registered S3 method overwritten by 'GGally':
  method from  
  +.gg   ggplot2
Registered S3 method overwritten by 'genetics':
  method      from
  [.haplotype pegas

Starting Error in cat("Starting", funname, "\n") :
  argument 2 (type 'language') cannot be handled by 'cat'
traceback()
2: cat("Starting", funname, "\n")
1: dartR::gl.filter.reproducibility(dartR::testset.gl)

The traceback seems to point to some issue with the cat function, but that appears to be working fine.
cat(paste(letters, 100* 1:26), fill = TRUE, labels = paste0("{", 1:10, "}:"))
{1}: a 100 b 200 c 300 d 400 e 500 f 600 g 700 h 800 i 900 j 1000 k 1100 l 1200 m 1300 n 1400 o 1500 p 1600 q 1700 r 1800 s 1900 t 2000
{2}: u 2100 v 2200 w 2300 x 2400 y 2500 z 2600

The text 'Starting' and the issue with cat() maybe suggests some issue with the part of the function on line 18-25 that read,
if (verbose >= 1) {
        if (verbose == 5) {
            cat("Starting", funname, "[ Build =", build, "]\n")
        }
        else {

            cat("Starting", funname, "\n")
        }
    }
But that is just hazarding a guess. This part of the function seems straightforward enough so I'm not sure why it would return an error

Regards,
Adam

Jose Luis Mijangos

unread,
Feb 13, 2022, 8:13:37 AM2/13/22
to dartR
Hello Adam,

Could you try using the beta version of dartR. You can install this version by using:

> devtools::install_github("green-striped-gecko/dartR@beta")

Then restart your R session and try:

> library(dartR)

> test <- gl.filter.reproducibility(testset.gl)

Cheers,
Luis

Adam Marques

unread,
Feb 17, 2022, 7:53:51 AM2/17/22
to dartR
Thank you Luis,

This appears to have solved the issue in most cases. I still had some issues and received the same error when applied to other functions, but I believe the issue may have been with my formatting.
As an example, I occasionally include the package name when calling a function, which appears to result in an error. Loading the package beforehand and excluding the package name in appears to have resolved the issue.
> dartR::gl.filter.reproducibility(testset.gl)
Starting ::
[...]
Completed: ::
 Completed: dartR
 Completed: gl.filter.reproducibility

 /// GENLIGHT OBJECT /////////
> dartR::gl.filter.maf(testset.gl)

Starting Error in cat("Starting", funname, "\n") :
  argument 2 (type 'language') cannot be handled by 'cat'

> gl.filter.maf(testset.gl)
  Processing genlight object with SNP data

Starting ::
 

Unrelated to the initial question, I stumbled upon an error with gl.filter.maf. The function begins to work but is intercepted by an error with the function sort.
If you would prefer this issue be set aside in another thread please let me know.
> gl.filter.maf(testset.gl)
  Processing genlight object with SNP data
Starting ::
[...]
Completed: ::
 Completed: dartR
 Completed: gl.report.maf

 Error in slot(x, name) :
  no slot of name "maf" for this object of class "genlight"
4. slot(x, name)
3. dartR::gl.report.maf(x)$maf
2. dartR::gl.report.maf(x)$maf at gl.filter.maf.R#28
1. gl.filter.maf(testset.gl)


Cheers,
Adam

Jose Luis Mijangos

unread,
Feb 17, 2022, 6:48:09 PM2/17/22
to dartR
Hello Adam,
 
Could you try using now the developing version of dartR. You can install this version by using:

> library(dartR)
   
> gl.install.vanilla.dartR(flavour = "dev")

 
Then restart your R session and try:
   
> library(dartR)
 
> dartR::gl.filter.maf(testset.gl)

or

> gl.filter.maf(testset.gl)

Cheers,
Luis

Adam Marques

unread,
Feb 22, 2022, 6:35:22 AM2/22/22
to dartR
Hello Luis,

Thank you for the suggestion. It appears installing the development version then running gl.filter.maf resolves the issue, but only temporarily.
After initially loading dartR, the functions will work with the test data, then after a run my study data, they will cease to work until I restart R.
> gl.filter.maf(testset.gl)
Starting gl.filter.maf
  Processing genlight object with SNP data
  Warning: genlight object contains monomorphic loci
Completed: gl.filter.maf
 /// GENLIGHT OBJECT /////////

> gl.filter.maf(study.data)
Error in slot(x, name) :
  no slot of name "maf" for this object of class "genlight"

This also appears elsewhere in my script.
For example, if I do not include population data gl.filter.maf returns an error (see below). I can generally avoid this error, by adding population data, but then I encounter the aforementioned error.
I've tried removing the population data from the testset, and it functions normally. However, after executing the function on my data, repeating the same function with the testset then returns an error.

> testset.gl@pop <- NULL
> gl.filter.maf(testset.gl)
Starting gl.filter.maf
  Processing genlight object with SNP data
  Population assignments not detected, individuals assigned to a single population labelled 'pop1'
  Warning: genlight object contains monomorphic loci
Completed: gl.filter.maf

 /// GENLIGHT OBJECT /////////
 
# Attempt to run my analysis
[...]
Error in .seppop_internal(x = x, pop = pop, treatOther = treatOther, keepNA = keepNA,  :
  pop not provided and pop(x) is empty


> gl.filter.maf(testset.gl)
Starting ::
 Starting dartR
 Starting gl.report.maf
  Processing genlight object with SNP data
Starting ::
 Starting dartR
 Starting gl.report.maf

 Error in .seppop_internal(x = x, pop = pop, treatOther = treatOther, keepNA = keepNA,  :
  pop not provided and pop(x) is empty
7. stop("pop not provided and pop(x) is empty")
6. .seppop_internal(x = x, pop = pop, treatOther = treatOther, keepNA = keepNA,
    quiet = quiet, ...)
5. .local(x, ...)
4. seppop(x)
3. seppop(x)
2. dartR::gl.report.maf(x) at gl.filter.maf.R#28
1. gl.filter.maf(testset.gl)


It seems as though running my analysis is somehow compromising the dartR functions, but the only steps that use dartR in this script merely pipe a genelight object to a series of functions.
> x
 /// GENLIGHT OBJECT /////////
 // 91 genotypes,  104,285 binary SNPs, size: 90.6 Mb
 1796565 (18.93 %) missing data
> x %>%
      gl.filter.reproducibility(t = genetic_data_parameters$repavg_threshold, v = 3) %>%
      gl.filter.callrate(method = "loc", threshold = genetic_data_parameters$locus_callrate_threshold, v = 3) %>%
      gl.filter.secondaries(method = genetic_data_parameters$sec_method, v = 3) %>%
      gl.filter.maf(threshold = genetic_data_parameters$min_maf, v = 1) %>%
      gl.filter.callrate(method = "ind", threshold = genetic_data_parameters$sample_callrate_threshold, v = 3)


Cheers,
Adam

Jose Luis Mijangos

unread,
Feb 22, 2022, 7:48:36 AM2/22/22
to dartR
Hello Adam,

Can you try:

study.data <- gl.compliance.check(study.data)
gl.filter.maf(study.data)

Could you please also let us know how did you read your data into dartR?

Cheers,
Luis

Adam Marques

unread,
Feb 24, 2022, 10:20:19 AM2/24/22
to dartR
Hello Luis,

I have found the issue, and it is entirely self inflicted.
It appears that as the scripts were initially developed with an older version of dartR before gl.filter.maf was included. The function was later added when it became available but sourced locally. I've disabled this now and it appears to be running smoothly.
My apologies for this oversight on my part. Thank you for all of your support.

Kindest regards,
Adam
Reply all
Reply to author
Forward
0 new messages