Extracts the factor loadings from a glPCA object (generated by gl.pcoa) and filters loci based on a user specified threshold for the ABSOLUTE value of the factor loadings.
gl.filter.factorloadings(
x,
pca,
axis = 1,
threshold,
retain = FALSE,
plot.display = TRUE,
plot.theme = theme_dartR(),
plot.colors = NULL,
plot.file = NULL,
plot.dir = NULL,
bins = 25,
verbose = NULL,
...
)
The unchanged genlight object
Name of the genlight object containing the SNP data or the SilocoDArT data [required].
Name of the glPCA object containing factor loadings [required].
Axis in the ordination used to display the factor loadings [default 1]
Numeric value for the factor loadings. This value is the ABSOLUTE value of the factor loadings [required].
If true, the resultant genlight object holds only the loci that load high on the specified axis; if FALSE, the resultant genlight object has the loci loading high on the specified axis filtered out [default FALSE].
If TRUE, resultant plots are displayed in the plot window [default TRUE].
Theme for the plot. See Details for options [default theme_dartR()].
List of two color names for the borders and fill of the plots [default c("#2171B5","#6BAED6")].
Name for the RDS binary file to save (base name only, exclude extension) [default NULL]
Directory to save the plot RDS files [default as specified by the global working directory or tempdir()]
Number of bins to display in histograms [default 25].
Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log; 3, progress and results summary; 5, full report [default NULL, unless specified using gl.set.verbosity]
Parameters passed to function ggsave, such as width and height, when the ggplot is to be saved.
Custodian: Arthur Georges -- Post to https://groups.google.com/d/forum/dartr
The function extracts the factor loadings for a given axis from a PCA object generated by gl.pcoa and then filters loci on the basis of a user specified threshold. The threshold value is decided using gl.report.factorloadings. The function can be used to filter out loci that load high with a particular axis or alternatively if retain=TRUE, to retain loci that load high on a specified axis.
Note that this function also removes monomorphic loci because PCA is performed only on polymorphic loci.
A color vector can be obtained with gl.select.colors() and then passed to the function with the plot.colors parameter.
Themes can be obtained from in
If a plot.file is given, the ggplot arising from this function is saved as an "RDS" binary file using saveRDS(); can be reloaded with readRDS(). A file name must be specified for the plot to be saved. If a plot directory (plot.dir) is specified, the ggplot binary is saved to that directory; otherwise to the tempdir().
pca <- gl.pcoa(testset.gl)
gl.report.factorloadings(pca = pca)
gl2 <- gl.filter.factorloadings(pca=pca,x=testset.gl,threshold=0.2)
Run the code above in your browser using DataLab