kfarleigh / popgenhelpr Goto Github PK
View Code? Open in Web Editor NEWPopGenHelpR is an R package that estimates commonly used population genomic statistics and generates publication quality figures.
License: GNU General Public License v3.0
PopGenHelpR is an R package that estimates commonly used population genomic statistics and generates publication quality figures.
License: GNU General Public License v3.0
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.
Some users receive an error stating that the color grey99 cannot be found when plotting in PopGenHelpR
v1.2.1 or earlier.
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")
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.