Giter Site home page Giter Site logo

kfarleigh / popgenhelpr Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 13.77 MB

PopGenHelpR is an R package that estimates commonly used population genomic statistics and generates publication quality figures.

License: GNU General Public License v3.0

R 99.96% Rez 0.04%
diversity fst heterozygosity interpolation neis population-genetics population-genomics r snmf structure

popgenhelpr's Introduction

Hi! Welcome to my GitHub. Check out the links below, and feel free to reach out with any questions or if you'd like to collaborate!

I am a bioinformatician and data scientist using next-generation sequencing and statistical approaches to investigate the processes and mechanisms that influence genomic and phenomic variation. Code here includes developed code and tools from my previous publications as well as in-development tools that I am currently working on.

Websites and Social Media

Background

Coding Languages

  • R
  • Python
  • BASH
  • Git
  • Markdown

popgenhelpr's People

Contributors

kfarleigh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

popgenhelpr's Issues

Error with mapping functions if rnaturalearthhires not installed.

The functions Plot_ancestry, Dif_Stats_Map, and Div_Stats_Map will throw an error if rnaturalearthhires is not installed. The solution is to install rnaturalearthhires using the code below.

# install devtools if needed
install.packages("devtools")
devtools::install_github("ropensci/rnaturalearthhires")

Error when knitting rmd file with mapping functions

Users may see the error below when using the Div_Stats_Map or Dif_Stats_Map` functions.

Error in ggplot2::geom_sf():

! Problem while setting up layer.
โ„น Error occurred in the 2nd layer.
Caused by error in sym():
! Can't convert NULL to a symbol.

Error when in ancestry functions when using Q-matrix from LEA

Some users are receiving error messages when using the ancestry functions (Ancestry_barchart and Piechart_map). See the error and solution below.

Errors
Error: object 'Ind_anc' not found
Error: Please supply input for plot.type. The options are 'all', 'individual', or 'population'.

Solution
The functions expect a q-matrix of type data.frame or a csv file where the first column contains sample names, followed by a column for each genetic cluster (K). LEA's Q function does not include sample names in its output and its output is a matrix, not a data.frame or q-matrix. So we need to add sample names and make sure that the columns representing the genetic cluster contribution are numeric.

Code

# If I have a sNMF project named my_project, an optimal K of 3, and my population assignment file is my_pops.csv with the sample names are in the column named Sample.
Qmat <- Q(my_project, K = 3, run = 1)
Loc <- read.csv("my_pops.csv")

# The qmatrix is created correctly; the problem is that it needs to be a data frame for input into the function
# So we add the individual name to the first column (the function needs this to reference the population assignment file)
# But this makes the columns a character which throws another error
# So we make the contribution columns numeric (sapply code)
Qmat_inds <- cbind(Loc$Sample, Qmat)
Qmat_inds_df <- as.data.frame.matrix(Qmat_inds) 

# Make the cluster contributions numeric
Qmat_inds_df[2:4] <- sapply(Qmat_inds_df[2:4], as.numeric)

## Now we can use the Q_mat_inds_df as input
Test_all_ind <- Ancestry_barchart(anc.mat = Qmat_inds_df, pops = Loc, K = 3 ,plot.type = 'individual', col = c('red','blue','purple'))
          
Test_all_pop <- Ancestry_barchart(anc.mat = Qmat_inds_df, pops = Loc, K = 3 ,plot.type = 'all', col = c('red','blue','purple'))

Please reach out if you have questions!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.