green-striped-gecko / PopGenReport

a simple way to analyse population genetic data using R
5 stars 5 forks source link

Error and missing output when running PopGenReport mk.null.all=T #1

Open EwersAquaGenomics opened 8 years ago

EwersAquaGenomics commented 8 years ago

Hi @green-striped-gecko !

I would like to use PopGenReport to calculate the proportion of null alleles in my microsat data. However, it throws an error when I run the github version, and does not seem to report the proportion of null alleles when I use the CRAN version. I have adegenet v 2.0.0 installed, and all other packages are current. Any help would be greatly appreciated!

Thanks, Christine

Here my example code:

library(devtools)
install_github("green-striped-gecko/PopGenReport")
library(PopGenReport)
data(nancycats)
x <- popgenreport(nancycats, mk.null.all=TRUE, mk.pdf=FALSE)

This code returns: Population 17 has 1 locus/loci with less than 3 genotypes. This may cause errors in some analyses. We advice to combine or drop populations with low numbers of genotypes. There is no results folder. I am trying to create it; otherwise please create the folder manually. Compiling report...

OR with CRAN version of PopGenReport

x <- popgenreport(nancycats, mk.null.all=TRUE, mk.pdf=FALSE)
x

output: $counts $counts$N [1] 237

$counts$numbypop 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Number 10 22 12 23 15 11 14 10 9 11 20 14 13 17 11 12 13

$counts$totalleles [1] 108

$counts$nallelesbypop 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Total number of alleles 36 53 50 67 48 56 42 54 43 46 70 52 44 61 42 40 35

$counts$nallelesbyloc fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca37 of alleles 16 11 10 9 12 8 12 12 18

$counts$meanalleles [1] 12

$counts$missing [1] 2.3

aaron-adamack commented 8 years ago

Hi Christine, Adegenet 2 has made a number of changes to genind objects which are causing problems with some of our functions.We are still in the process of updating popgenreport to work with adegenet 2. If you go back to the prior version of adegenet (v1.xx), and use the CRAN version of popgenreport it should help to solve the problem you're having. If you're still having problems with your code, I can take a look at your code and see what's up.

-Aaron

On 25/07/2015 12:24 AM, "Christine Ewers-Saucedo" notifications@github.com wrote:

Hi @green-striped-gecko https://github.com/green-striped-gecko !

I would like to use PopGenReport to calculate the proportion of null alleles in my microsat data. However, it throws an error when I run the github version, and does not seem to report the proportion of null alleles when I use the CRAN version. I have adegenet v 2.0.0 installed, and all other packages are current. Any help would be greatly appreciated!

Thanks, Christine

Here my example code:

library(devtools) install_github("green-striped-gecko/PopGenReport") library(PopGenReport) data(nancycats)x <- popgenreport(nancycats, mk.null.all=TRUE, mk.pdf=FALSE)

This code returns: Population 17 has 1 locus/loci with less than 3 genotypes. This may cause errors in some analyses. We advice to combine or drop populations with low numbers of genotypes. There is no results folder. I am trying to create it; otherwise please create the folder manually. Compiling report...

  • General summary...
    • No valid coordinates were provided. Be aware you need to provide a coordinate (or NA) for each individual and the coordinate heading in slot @other https://github.com/other has to be 'latlong' or 'xy'. Some of the analyses require coordinates and will be skipped!
    • Checking for null alleles ... Analysing data ... All files are available in the folder: /var/folders/sh/9gq4xtb968z45j7p2vp2f9kc0000gn/T//RtmpI1682r/results Warning message: In mean.default(sumcats$loc.n.all) : argument is not numeric or logical: returning NA

OR with CRAN version of PopGenReport

x <- popgenreport(nancycats, mk.null.all=TRUE, mk.pdf=FALSE)x

output: $counts $counts$N [1] 237

$counts$numbypop 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Number 10 22 12 23 15 11 14 10 9 11 20 14 13 17 11 12 13

$counts$totalleles [1] 108

$counts$nallelesbypop 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Total number of alleles 36 53 50 67 48 56 42 54 43 46 70 52 44 61 42 40 35

$counts$nallelesbyloc fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca37 of alleles 16 11 10 9 12 8 12 12 18

$counts$meanalleles [1] 12

$counts$missing [1] 2.3

— Reply to this email directly or view it on GitHub https://github.com/green-striped-gecko/PopGenReport/issues/1.

elizeng commented 8 years ago

Has PopGenReport been updated to work with adegenet v2 onwards? I have been unable to generate reports with PopGenReport when loading genind files with adegenet v2.0.1.

green-striped-gecko commented 8 years ago

Hi update using the link here and it should work fine. or simply update using cran should work as well.

let me know if there are still errors.

www.popgenreport.orghttp://www.popgenreport.org

cheers, Bernd


Bernd Gruber

Associate Professor

Spatial and Ecological Modelling

Institute for Applied Ecology

P 02 620638tel:02%206206382404 E bernd.gruber@canberra.edu.aumailto:amy.dobos@canberra.edu.au

appliedecology.edu.auhttp://appliedecology.edu.au/

University of Canberra, ACT 2617

[cid:773E8FD9-259B-42DE-B032-8786C1547AA3]

NOTICE & DISCLAIMER: This email and any files transmitted with it may contain confidential or copyright materials and are for the attention of the addressee only. If you have received this email in error please notify us by email reply and delete it from your system. The University of Canberra accepts no liability for any damage caused by any virus transmitted by this email.Australian Government Higher Education (CRICOS)Registered Provider number: #00212K

On 1 Mar 2016, at 20:43, lilnet notifications@github.com<mailto:notifications@github.com> wrote:

Has PopGenReport been updated to work with adegenet v2 onwards? I have been unable to generate reports with PopGenReport when loading genind files with adegenet v2.0.1.

Reply to this email directly or view it on GitHubhttps://github.com/green-striped-gecko/PopGenReport/issues/1#issuecomment-190636553.

elizeng commented 8 years ago

Hi @green-striped-gecko,

I am trying to get PopGenReport to calculate genetic distances and do PCoA and ran into the same error and missing output. This time with adegenet v2.0.1 and PopGenReport v2.2.

The same code works without error and missing output for the example dataset platypus2c.csv as illustrated in https://cran.r-project.org/web/packages/PopGenReport/vignettes/PopGenReportIntroduction.pdf

Could there be a problem with the genind object caused by adegenet v2.0.1?

UPDATE: After trying many combinations, PopGenReport v2.2.1 works with adegenet v2.0.0 (did not try with adegenet v2.0.1 though). PopGenReport v2.2.1 has to be installed via CRAN and not install.packages.

> data("nancycats")
> nancycats
/// GENIND OBJECT /////////

 // 237 individuals; 9 loci; 108 alleles; size: 129.4 Kb

 // Basic content
   @tab:  237 x 108 matrix of allele counts
   @loc.n.all: number of alleles per locus (range: 8-18)
   @loc.fac: locus factor for the 108 columns of @tab
   @all.names: list of allele names for each locus
   @ploidy: ploidy of each individual  (range: 2-2)
   @type:  codom
   @call: genind(tab = truenames(nancycats)$tab, pop = truenames(nancycats)$pop)

 // Optional content
   @pop: population of each individual (group size range: 9-23)
   @other: a list containing: xy 

> ncats<-popgenreport(nancycats, mk.gd.smouse = TRUE, mk.pcoa = TRUE, mk.pdf=FALSE, foldername = "results.ncats", path.pgr=getwd())
Population P17 has 1 locus/loci with less than 3 genotypes. This may cause errors in some analyses. We advice to combine or drop populations with low numbers of genotypes. 
There is no  results.ncats  folder. I am trying to create it; 
otherwise please create the folder manually. 
Compiling report...
- General summary...
 - No valid coordinates were provided. 
   Be aware you need to provide a coordinate (or NA) for each individual
   and the coordinate heading in slot @other has to be 'latlong' or 'xy'.
   Some of the analyses require coordinates and will be skipped!
- Principal coordinate analysis following Jombart et al. 2009...
Analysing data ...
> ncats
$counts
$counts$N
[1] 2.344116

$counts$numbypop
<0 x 0 matrix>

$counts$totalleles
[1] 108

$counts$nallelesbypop
<0 x 0 matrix>

$counts$nallelesbyloc
             fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca37
# of alleles   16    11    10     9    12     8    12    12    18

$counts$meanalleles
[1] 12

$counts$missing
[1] 2.3

Current package versions

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 (build 7601) Service Pack 1

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] devtools_1.10.0     data.table_1.9.6    GGally_1.0.1        ggplot2_2.0.0      
 [5] vegan_2.3-3         permute_0.9-0       gdistance_1.1-9     Matrix_1.2-3       
 [9] igraph_1.0.1        reshape_0.8.5       R.utils_2.2.0       R.oo_1.20.0        
[13] R.methodsS3_1.7.1   dismo_1.0-15        mmod_1.3.1          plyr_1.8.3         
[17] xtable_1.8-2        calibrate_1.7.2     lattice_0.20-33     gap_1.1-16         
[21] genetics_1.3.8.1    mvtnorm_1.0-5       MASS_7.3-45         gtools_3.5.0       
[25] gdata_2.17.0        combinat_0.0-8      pegas_0.8-2         ape_3.4            
[29] RgoogleMaps_1.2.0.7 PopGenReport_2.2    raster_2.5-2        sp_1.2-2           
[33] knitr_1.12.3        adegenet_2.0.1      ade4_1.7-3      
green-striped-gecko commented 8 years ago

Hi,

I think the problem is with the nancycats coordinates. Here are only coordinates per population and not per individual specified. So you would need to convert them into coordinates per individuals.

nancycats@other$xy<- nancycats@other$xy[pop(nancycats),]

should do the trick.

Cheers, Bernd

If you look closely in the error message it states:

From: lilnet [mailto:notifications@github.com] Sent: Tuesday, 1 March 2016 21:50 To: green-striped-gecko/PopGenReport Cc: Bernd Gruber Subject: Re: [PopGenReport] Error and missing output when running PopGenReport mk.null.all=T (#1)

Hi @green-striped-geckohttps://github.com/green-striped-gecko,

I am trying to get PopGenReport to calculate genetic distances and do PCoA and ran into the same error and missing output. This time with adegenet v2.0.1 and PopGenReport v2.2.

The same code works without error and missing output for the example dataset platypus2c.csv as illustrated in https://cran.r-project.org/web/packages/PopGenReport/vignettes/PopGenReportIntroduction.pdf

Could there be a problem with the genind object caused by adegenet v2.0.1?

data("nancycats")

nancycats

/// GENIND OBJECT /////////

// 237 individuals; 9 loci; 108 alleles; size: 129.4 Kb

// Basic content

@tab: 237 x 108 matrix of allele counts

@loc.n.all: number of alleles per locus (range: 8-18)

@loc.fac: locus factor for the 108 columns of @tab

@all.names: list of allele names for each locus

@ploidy: ploidy of each individual (range: 2-2)

@type: codom

@call: genind(tab = truenames(nancycats)$tab, pop = truenames(nancycats)$pop)

// Optional content

@pop: population of each individual (group size range: 9-23)

@other: a list containing: xy

ncats<-popgenreport(nancycats, mk.gd.smouse = TRUE, mk.pcoa = TRUE, mk.pdf=FALSE, foldername = "results.ncats", path.pgr=getwd())

Population P17 has 1 locus/loci with less than 3 genotypes. This may cause errors in some analyses. We advice to combine or drop populations with low numbers of genotypes.

There is no results.ncats folder. I am trying to create it;

otherwise please create the folder manually.

Compiling report...

Analysing data ...

ncats

$counts

$counts$N

[1] 2.344116

$counts$numbypop

<0 x 0 matrix>

$counts$totalleles

[1] 108

$counts$nallelesbypop

<0 x 0 matrix>

$counts$nallelesbyloc

         fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca37

of alleles 16 11 10 9 12 8 12 12 18

$counts$meanalleles

[1] 12

$counts$missing

[1] 2.3

— Reply to this email directly or view it on GitHubhttps://github.com/green-striped-gecko/PopGenReport/issues/1#issuecomment-190660248.