Giter VIP home page Giter VIP logo

ggordiplots's People

Contributors

jfq3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

devanmcg

ggordiplots's Issues

Issue installing

Hi,

I keep having issues with installing ggordiplots. I am probably doing something wrong.

install_github("jfq3/ggordiplots")

This gives the following error message: Downloading GitHub repo jfq3/ggordiplots@HEAD
Error in utils::download.file(url, path, method = method, quiet = quiet, :
cannot open URL 'https://api.github.com/repos/jfq3/ggordiplots/tarball/HEAD'

Is there a work around?

Best,
Berry van der Hoorn

Difficulty plotting NMDS

Hello,

I am trying to plot an NMDS output from metaMDS(), which successfully plotted using ggplot(). I am trying to use ggordiplot to plot the same ordination and use the gg_envfit function to more easily add environmental vectors, however the plot itself isn't looking right. I can't get the right axes to be plotted.

##GGPLOT PLOT:
##PLOTTING NMDS

toPlot <- data.frame(NMDS1$points, Sample_ID = metadata$Sample_ID);
a <- ggplot(toPlot, aes(-MDS1, MDS2, colour=Sample_ID)) +
    geom_point(size=3) +
    xlab("NMDS1") +
    ylab("NMDS2") +
    theme(axis.text = element_blank(),
          axis.ticks = element_blank(),
          axis.title = element_text(size = 20),
          legend.text = element_text(size = 20),
          legend.title = element_text(size = 20),
          #legend.key.size = unit(1.0, "cm"),
          legend.key = element_rect(colour = "gray"));
    


a <- a + theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
                            panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"));
a

image

However when I plot using gg_ordiplot my output looks like this:

image

I cannot figure out how to change the axes.

I am sorry if this is a very remedial question - I am new to R and trying to figure it out as I go! Thank you!

Adding species arrows to PCA

Hi @jfq3,

I've made a PCA using the rda function of the vegan package. After taht, I decided to use the ggordiplots package to plot my PCA because I needed to plot standard error centroid at 95% confidence.

My code is the following:
myplot <- gg_ordiplot(pca.rda, groups = mydata$Species, kind="se", conf=0.95, pt.size =1)

I would like now to add the arrows that represents the "species" scores of the PCA.

Is that possible?
Thank you,

Customize_gg_ordisurf

Great code, would it be available on CRAN?.

I would like to customize my plot. This is probably a bit naive, but any help would be greatly appreciated:

1- Ticken curves,
2- colour dots by groups

p= gg_ordisurf(bird.nmds, env.var = bird.all.xy$Elevation, var.label="Elevation")

p$plot +theme_bw(base_size = 19) +
theme(panel.grid = element_blank(),
legend.position="none")+
xlim(-1, 1.2)+ ylim(-0.5,0.5)+
scale_colour_gradient(low = "green", high = "red", na.value = NA)+
labs(x=paste0("NMDS-1"),
y=paste0("NMDS-2 "), title = "Bird communities")

image

R 4.2.1

Using R 4.2.1 I get the message "Warning: package ‘ggordiplots’ is not available for this version of R". Would it be possible to update ggordiplots to allow it to work with the latest version of R?

Issue Loading Library

Hi! I think this is a great idea for an R package. Unfortunately, after installation I was not able to load the library. Here is the error:

library(ggordiplots)
Error: package or namespace load failed for ‘ggordiplots’ in get(Info[i, 1], envir = env):
lazy-load database '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/ggplot2/R/ggplot2.rdb' is corrupt
In addition: Warning message:
In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1

This is on a Mac, running Rstudio and R version 3.4.0

Thanks,

Ran

Removing axes

I am plotting the results of an NMDS ordination, and would like to remove axes tick marks, text, and titles. Is there a way to do this for gg_ordiplot? I have looked through the ggordiplots documentation and have tried standard ggplot2 syntax to do so, but have been unsuccessful.

problems installing the 'ggordiplots' package

Hi John, I am having problems installing the 'ggordiplots' package, I have vegan and ggplot2 installed, I have tried installing using:
1.
remotes::install_github("jfq3/ggordiplots")
Using github PAT from envvar GITHUB_PAT
Error: Failed to install 'unknown package' from GitHub:
HTTP error 401.
Bad credentials

Rate limit remaining: 43/60
Rate limit reset at: 2022-09-15 18:32:56 UTC
2. I tried that too:
remotes::install_github('jfq3/ggordiplots', auth_token = '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')
Error: Failed to install 'unknown package' from GitHub:
HTTP error 401.
Bad credentials

What can I do, please? Love your graphics!

thanks
Ana

Add Ellipse in Plot

Hi John,

I'm unable to add ellipse to a PCOA plot that has both shape and color.
I tried doing the same with the data the you showed in 'Modifying Plots Made with ggordiplot". Here is my workflow:

library(vegan)
#> Loading required package: permute
#> Loading required package: lattice
#> This is vegan 2.5-6
library(ggordiplots)
#> Loading required package: ggplot2
library(ggplot2)
data("dune")
data("dune.env")
dune.bray <- vegdist(dune, method = "bray")
ord <- cmdscale(dune.bray, k = nrow(dune) - 1, eig = TRUE, add = TRUE)

my.plot <- gg_ordiplot(ord, groups = dune.env$Management, hull = FALSE, spiders = FALSE, ellipse = TRUE, plot = FALSE)
names(my.plot)
#> [1] "df_ord"      "df_mean.ord" "df_ellipse"  "df_hull"     "df_spiders" 
#> [6] "plot"

ord.data <- my.plot$df_ord
head(ord.data)
#>             x           y Group
#> 1 -0.41304599 -0.29334952    SF
#> 2 -0.36336280 -0.23194350    BF
#> 3 -0.09544153 -0.37700777    SF
#> 4 -0.09071908 -0.33989216    SF
#> 5 -0.38379168  0.03964464    HF
#> 6 -0.32237706  0.12912569    HF
ord.data$Use <- dune.env$Use
colnames(ord.data) <- c("x", "y", "Management", "Use")
head(ord.data)
#>             x           y Management      Use
#> 1 -0.41304599 -0.29334952         SF Haypastu
#> 2 -0.36336280 -0.23194350         BF Haypastu
#> 3 -0.09544153 -0.37700777         SF Haypastu
#> 4 -0.09071908 -0.33989216         SF Haypastu
#> 5 -0.38379168  0.03964464         HF Hayfield
#> 6 -0.32237706  0.12912569         HF Haypastu

The following code gave error Error in FUN(X[[i]], ...) : object 'Use' not found

ggplot(data = ord.data, aes(x = x, y = y, color = Management, shape = Use)) +
  geom_point(size = 3) + 
  geom_path(data = my.plot$df_ellipse, aes(x = x, y = y, color = Group))

Adding 'Use' to my.plot$df_ellipse doesn't work as well due to unequal sample rows. I think I'm missing something here.

Thanks for your help!

Adjusting height of gg_ordiplots() plot

Hello,

I am wondering if there is a way to make the plot from gg_ordiplot() flexible in the vertical direction as you adjust your plot size? It currently seems scale-invariant, which makes it difficult to combine with other ggplot-derived plots. I am currently using ggarrange() to combine my PERMADISP results with the original ordination. Any advice would be greatly appreciated! Screenshots attached of what I mean:
Screen Shot 2021-09-16 at 1 03 04 PM
Screen Shot 2021-09-16 at 1 03 19 PM

The top image shows the dimensions of my plot screen that are necessary to have all of the x-axes aligned with each other, while the bottom image shows what happens when I make the view screen narrower. When I make the screen narrower, the right ordination and left boxplot automatically adjust to the height of the view screen, while the ordiplot in the center does not fill the vertical space, if that makes sense. Hope my question makes sense, and thanks in advance for your help!

Changing line type and color using ggordiplot

Hi @jfq3 ,
I am trying to color and format (type) the lines on a plot based on different columns of metadata from which I make the plot. I make the attached plot using the following code:

library(ggordiplots)
m <- gg_ordiplot(ord, sd_ps$Infestation_Stage_Soil, choices = c(1, 2), kind = c("se"), conf = 0.95, show.groups = "all", ellipse = TRUE, label = TRUE, hull = FALSE, spiders = FALSE, plot = TRUE, pt.size = 1.5) 
m<-m$plot + theme_bw() 
m <-m + annotate("text", x = -1, y = -1, label = "Soil Origin: p > 0.15")
m <-m + annotate("text", x = -1, y = -1.15, label = "Infestation Stage: p < 0.001")
m <-m + annotate("text", x = -1, y = -1.3, label = "K=3, Stress=0.179")
m <- m + ggtitle("NMDS of Infestation Stage and Soil Origin", ) +
  theme(plot.title = element_text(hjust = 0.5, size = 22)) 
m <- m + guides(color=guide_legend("Infestation Stage and Soil Origin"))
m

image

What I would like to do is have a dashed line and a solid line for the two Soil Origins (bulk and rhizosphere) and a then use only three colors for the three infestation stages (healthy (green), infested (red) and dead (grey)).

The data for these two factors are stored in my metadata (sd_ps$Soil and sd_ps$Infestation_Stage)

I have tried the following argument but i get an error stating :
additional line of code:

m<-m+ geom_line(data = sd_ps, aes(linetype = Soil))

Error:
Error in order(data$PANEL, data$group, data$x) : argument 3 is not a vector

I would like to use this package because of the "se" option for the ellipses. I have not been able to incorporate this option into any other ggplot option.

Any ideas?

Thanks,
Gordon

Adding ggordiplot ellipse to Ampvis2 ordination plot

Hi John,

Thanks for developing ggordiplot. I would like to use the ordination plots from Ampvis2 package instead of building ordination plot from scratch. I was just wondering if it is possible to incorporate the ellipse function used in ggordiplot into the Ampvis2 plots. Here is an example workflow:

library(ampvis2)
#> Loading required package: ggplot2

data("MiDAS")
MiDASsubset <- amp_subset_samples(MiDAS, Plant %in% c("Aalborg West", "Aalborg East"))
#> 590 samples and 5512 OTUs have been filtered 
#> Before: 658 samples and 14969 OTUs
#> After: 68 samples and 9457 OTUs
amp_ordinate(MiDASsubset, 
             type = "pcoa",
             distmeasure = "bray",
             sample_color_by = "Plant")
#> Calculating distance matrix...
#> Done.
#> Warning: Using both transformation AND a distance measure is not
#> recommended for distance-based ordination (nMDS/PCoA/DCA). If this is not
#> deliberate, consider transform = "none".

Created on 2019-09-11 by the reprex package (v0.3.0)

Thanks!

Release ggordiplots 0.4.2

First release:

Prepare for release:

  • git pull
  • usethis::use_github_links()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

Add family argument to gg_ordisurf

Hi! Thanks for making such a helpful package. It would be nice to have a family argument in gg_ordisurf to allow vegan::ordisurf to take different response families. This seems to work on my end -

gg_ordisurf <- 
  function (ord, env.var, groups = NA, choices = c(1, 2), var.label = "Level", 
          binwidth, pt.size = 3, plot = TRUE, family = "gaussian") 
{
  groups <- as.factor(groups)
  ordi <- vegan::ordisurf(ord ~ env.var, plot = FALSE, family = family)
  ordi.grid <- ordi$grid
  ordi.data <- expand.grid(x = ordi.grid$x, y = ordi.grid$y)
  ordi.data$z <- as.vector(ordi.grid$z)
  df_surf <- data.frame(na.omit(ordi.data))
  df_ord <- as.data.frame(scores(ord, choices = choices, display = "sites"))
  if (is.na(groups)[1]) {
    df_ord <- data.frame(x = df_ord[, 1], y = df_ord[, 2])
  }
  else {
    df_ord <- data.frame(x = df_ord[, 1], y = df_ord[, 2], 
                         Group = groups)
  }
  axis.labels <- ord_labels(ord)[choices]
  xlab <- axis.labels[1]
  ylab <- axis.labels[2]
  if (missing(binwidth)) {
    r <- range(env.var)
    binwidth <- (r[2] - r[1])/15
  }
  if (is.na(groups)[1]) {
    plt <- ggplot() + geom_point(data = df_ord, aes(x = x, 
                                                    y = y), size = pt.size) + xlab(xlab) + ylab(ylab) + 
      stat_contour(data = df_surf, aes(x = x, y = y, z = z, 
                                       color = ..level..), binwidth = binwidth) + labs(color = var.label) + 
      coord_fixed(ratio = 1)
  }
  else {
    plt <- ggplot() + geom_point(data = df_ord, aes(x = x, 
                                                    y = y, fill = Group), shape = 21, color = "#00000000", 
                                 size = pt.size) + xlab(xlab) + ylab(ylab) + stat_contour(data = df_surf, 
                                                                                          aes(x = x, y = y, z = z, color = ..level..), binwidth = binwidth) + 
      labs(color = var.label) + coord_fixed(ratio = 1)
  }
  if (plot) {
    print(plt)
  }
  invisible(list(df_ord = df_ord, df_surf = df_surf, plot = plt))
}

Trouble installing package

Hi,
I'm having trouble installing ggordiplots in rstudio, i have ggplot2 and vegan installed but i keep getting the following errors:

install.packages("ggordiplots"): Warning in install.packages package ‘ggordiplots’ is not available (for R version 3.6.2)

remotes::install_github("jfq3/ggordiplots"):
Error: Failed to install 'ggordiplots' from GitHub:
(converted from warning) cannot remove prior installation of package ‘digest’

Could you tell me how to install this package?
thanks

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.