Giter Site home page Giter Site logo

ggord's Introduction

ggord

Marcus W. Beck, [email protected]

R-CMD-check DOI

A simple package for creating ordination plots with ggplot2. View the website for an overview: https://fawda123.github.io/ggord

Installation

Install the package as follows:

# Enable the r-universe repo
options(repos = c(
    fawda123 = 'https://fawda123.r-universe.dev',
    CRAN = 'https://cloud.r-project.org'))

# Install ggord
install.packages('ggord')

Citation

Please cite the current release as follows:

Marcus W. Beck (2022). ggord: Ordination Plots with ggplot2. R package version 1.1.7. https://zenodo.org/badge/latestdoi/35334615

Contribution and issues

For making contributions to this package, please see the instructions on the contributing page.

For bugs or feature requests, please follow the instructions here.

ggord's People

Contributors

fawda123 avatar vmikk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ggord's Issues

Is there an option to define color for the labels of the vectors?

As the title says, I couldn't find an option to define the label for the vectors. Maybe I missed it. Could you please advise if there is a way to define colors for labels?

I can change the color of the vectors using veccol but am unable to change the color of the labels as well.

point and font size in CA

Hi Marcus,

Is it possible to change the point and font size of the points and factor name labels in the CA graph of ggord?
Thank you,
Emily

Error when using just one explanatory variable in a RDA model

Function ggord throws an error then plotting a RDA result. Everything works fine if I have more than one explanatory variable in my model. However, with just one explanatory variable I got the error: Error in ord_in$CCA$wa[, axes] : subscript out of bounds (?)

Any help is very much appreciated....

library(ggord)
#> Warning: Paket 'ggord' wurde unter R Version 4.1.2 erstellt
library(vegan)
#> Lade nötiges Paket: permute
#> Lade nötiges Paket: lattice
#> This is vegan 2.5-7

data(dune)
data(dune.env)

model<-rda (dune ~ Condition(Moisture) + A1, scale=F,data = dune.env)
ggord(model)
#> Error in ord_in$CCA$wa[, axes]: Indizierung außerhalb der Grenzen
ggord(model, dune.env$Moisture,ellipse = FALSE,sizepch=10,txt = 4,size=2,repel=T,alpha=0.7, addpch=3,addcol="black")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+ggtitle("")+ theme(legend.position="none")
#> Error in ord_in$CCA$wa[, axes]: Indizierung außerhalb der Grenzen

Created on 2022-01-26 by the reprex package (v2.0.0)

Ordination plots need equal coordinate scalings

The axes on ordinations need to be scaled in the same units and have an aspect ratio of 1. To achieve this with ggplot2, add a + coord_fixed() layer to the plot when drawn by ggord(). This is required to maintain the metric interpretations of distances on the plots.

arrow lines in CA plot

Thank you for replying to my message. What I would like to do is remove the arrow lines from the plot, but keep the vector labels. Similar to the Factominer CA, with the vectors as triangles or points in the graph (or just the label names). The arrow lines just make the graph very busy with large datasets.

Thanks!
Em

I can't install ggord

Issues

Hello,

I would like to install ggord so I did:
library(devtools)
devtools::install_github('fawda123/ggord')
library(ggord)

But after I had this error:
Erreur : Failed to install 'ggord' from GitHub:
create process 'C:/PROGRA1/R/R-401.3/bin/x64/Rcmd.exe' (system error 267, Nom de répertoire non valide.
) @win/processx.c:1040 (processx_exec)

I reinstalled the last version of RTools and I had the last version of R. I also tried the commands:
devtools::install_github("r-lib/rlang")
OR
install.packages("rlang",type="win.binary")

But I had the same error.

What can I do to install your package? I think it is because I have an accent on my computer username C:/ but I can't change it.

Word 'italic' showing up in rda plots

Issues

Any issues or feature requests can be posted on the issues page. Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or send me a direct message.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.


When running ggord on an rda from package vegan, the species names include the word 'italic'. I edited the ggord.default function in my own script file to fix it, but I wanted to let you all know.
I am using R version 4.0.
Below is my fix to ggord.default, but I expect there is a better way. The ### indicate a line that I edited.

  • My fix to ggord.default
 # add species scores if addpts not null, for triplot
  if(!is.null(addpts)){

    addpts$lab <- paste0('', row.names(addpts), '') ###
    nms <- names(addpts)[1:2]
    names(addpts)[1:2] <- c('one', 'two')

    # pts as text labels if TRUE
    if(ptslab){
      p <- p +
        geom_text(data = addpts, aes_string(x = 'one', y = 'two', label = 'lab'),
          size = addsize, col = addcol, alpha = alpha, parse = parse, fontface=3) ###
    } else {
      p <- p +
        geom_point(data = addpts, aes_string(x = 'one', y = 'two'),
          size = addsize, col = addcol, alpha = alpha, shape = addpch)
    }
  }

  • Example
easypackages::libraries("ggplot2", "ggord", "vegan")

data(dune)
data(dune.env)
dune.Manure <- rda(dune ~ Manure, dune.env)

ggord(dune.Manure, ptslab = TRUE, ellipse = FALSE, hull=TRUE, poly=FALSE, repel=T, veclsz = 0.75)

reprex-ggord rda italics issue

Group and facet ggord plot using separate variables

Issues

I want to plot my ordination results so that they are grouped by one variable (specified with the 'grp_in' argument) and faceted by another. Is this possible for ggord? Using facet_wrap separately hasn't worked.

Here is a reproducible example using the iris dataset. I want to group my ordination results by 'Species' but facet them by 'Petal.color'.

library(ggplot2)
library(ggord)

iris$Petal.color <- as.factor(rep(c("purple", "white", "blue"), times = 50))
ord <- prcomp(iris[, 1:4])

ggord(ord, iris$Species)  # How to facet by Petal.color and not Species?? 
# ggord(ord, iris$Species) + facet_wrap(~iris$Petal.color)  ## This line returns an error message, listed below 
# Error: Error in `$<-.data.frame`(`*tmp*`, "PANEL", value = c(2L, 3L, 1L, 2L,  : replacement has 150 rows, data has 168

Plotting on variables or cases

Hi
I have a lot of variables and its creating a messy plot. I can't get var.sub to subset the variables. I wish to either plot only cases, or subset the variables to those which are most variant. Please can you assist me in this
Thanks
Aedin

grp_in parameter question

Hi,

I found the parameter "grp_in" was only worked on more than 2 replicates. If I want to use 2 replicates for each group. It reported the error :"Error in names(ell) <- *vtmp* : 'names' attribute [3] must be the same length as the vector [0]". Could you improve the parameter to work well with 2 replicates?

Thanks!

Small things to fix...

library(ade4)
ord <- dudi.pca(iris[, 1:4], scannf = FALSE, nf = 2, center=TRUE, scale=TRUE)
ggord(ord, iris$Species) # TO DO: something wrong here with explained variance and scaling (different than prcomp, PCA and princomp)

# this gives the correct result :
library("devtools")
install_github("kassambara/factoextra")
library("factoextra")
ord <- dudi.pca(iris[, 1:4], scannf = FALSE, nf = 2, center=TRUE, scale=TRUE)
fviz_pca_biplot(ord,  # gives the correct result
                habillage = iris$Species, addEllipses = TRUE,
                col.var = "red", alpha.var ="cos2",
                label = "var") 
# see factoextra/R/get_pca.R
  1. for dudi.coa
# dudi.coa
library(ade4)
ord <- dudi.coa(iris[, 1:4], scannf = FALSE, nf = 4)
ggord(ord, iris$Species) # TO DO: scaling correct but %s on axes not correct
fviz_ca_biplot(ord,  # correct solution
               habillage = iris$Species, addEllipses = TRUE,
               col.var = "red", label = "var")
# see factoextra/R/get_ca.R
# ca
library(ca)
ord <- ca(iris[, 1:4])
ggord(ord, iris$Species) # TO DO: scaling not correct, %s on axes correct
fviz_ca_biplot(ord,  # correct solution
               habillage = iris$Species, addEllipses = TRUE,
               col.var = "red", label = "var") 
# see factoextra/R/get_ca.R
# acm
library(ade4)
ord <- dudi.acm(tea[, -1], scannf = FALSE)
ggord(ord, tea$Tea) # TO DO: similar to MCA, but %s on axes not correct
fviz_mca_biplot(ord,  # correct solution
                habillage = tea$Tea, addEllipses = TRUE,
                col.var = "red", label = "var")
# see factoextra/R/get_mca.R
# mca
library(MASS)
ord <- mca(tea[, -1])
ggord(ord, tea$Tea) # TO DO: scaled differently as MCA and %s on axes not correct, mistake here?
# see factoextra/R/get_mca.R

Reducing number of vectors

Hi:

Is it possible to reduce the number of plotted vectors on an ordination plot? I want to make an nmds plot and my vectors (species) are too many, obscuring the graph. Is there a way to define which vectors to plot, e.g. by setting a threshold on the abundance?

Impossible to install with R 4.2.1

Issues

Impossible to install with R 4.2.1

Brief description of the problem

# Enable the r-universe repo
options(repos = c(
+     fawda123 = 'https://fawda123.r-universe.dev',
+     CRAN = 'https://cloud.r-project.org'))
 
# Install ggord
install.packages('ggord')
Warning in install.packages :
  unable to access index for repository https://fawda123.r-universe.dev/src/contrib:
  cannot open URL 'https://fawda123.r-universe.dev/src/contrib/PACKAGES'
Warning in install.packages :
  unable to access index for repository https://fawda123.r-universe.dev/src/contrib:
  cannot open URL 'https://fawda123.r-universe.dev/src/contrib/PACKAGES'
Warning in install.packages :
  packageggordis not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
Warning in install.packages :
  unable to access index for repository https://fawda123.r-universe.dev/bin/macosx/contrib/4.2:
  cannot open URL 'https://fawda123.r-universe.dev/bin/macosx/contrib/4.2/PACKAGES'

Thanks for the support.

Changing point shape with different grouping variable

Issues

Any issues or feature requests can be posted on the issues page. Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or send me a direct message.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.


Brief description of the problem

# insert reprex here

Travis builds are breaking....

Builds work fine on local Windows machine using devtools::check().

Full Travis log here. The offending information from R CMD check on the log:

Checking URLs requires 'libcurl' support in the R build
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package required but not available: ‘ggplot2’

Package suggested but not available: ‘FactoMineR’

The suggested packages are required for a complete check.
Checking can be attempted without them by setting the environment
variable _R_CHECK_FORCE_SUGGESTS_ to a false value.

Add species name in ggord() db-RDA plotting

Hi @fawda123,

It's my first time to try to analyze microbiome data with db-RDA ordination strategy.

Through the webpage: https://fukamilab.github.io/BIO202/06-B-constrained-ordination.html I used your package with my own data and the output likes to me.
db-RDAtrial

Nevertheless I would like to know if it is possible to indicate the species name and if exists some restriction as occurs if I follow plot() function with only permits the plot of the name of 80 species and no more. I have 220 species but I would like to plot the species labels that are from >0.25 in axis values.

Thanks on advance for your help,

David.

Request - GGord repel = True AND maxoverlap / force

Issues

Any issues or feature requests can be posted on the issues page. Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or send me a direct message.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.


This is mostly a request, altough i wanted to ask first but i couldnt find anywhere to reach you (I even went to your wordpress); please, add a mail or something to contact in your home// send you the stackoverflow questions. (Or politely show them to mee cause it could be despise me searching for it that im blind as a bat)

Since i have not found how to vary the intra-arguments of ggrepel using ggord, just aplying true, i request thee.

When dealing with high correlated vectors from a ggord, like a pca, the ggrepel overlaps and i didnt manage to change the max_overlaps and/or the force so i could easily read the variables. I wish i had a reproducible example, but i cant find some free repositorys with the same issue as my data (wich i do not own to send/post)

All in all, thank you in advance and of course for this marvelous package :D.

# insert reprex here

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.