Code Monkey home page Code Monkey logo

Comments (7)

Hy4m avatar Hy4m commented on August 25, 2024

you can

set linetype = 'dashed' parameter in geom_couple() layer function.

from linket.

B-1991-ing avatar B-1991-ing commented on August 25, 2024

Is there a way to set the negative Mantel's r with dashed lines and positive Mantel's r with solid lines?
If directly set the livetype = "dashed", all lines will be dashed.

image

from linket.

B-1991-ing avatar B-1991-ing commented on August 25, 2024

I also want to know the positive or negative relationship between the matrixes.

from linket.

B-1991-ing avatar B-1991-ing commented on August 25, 2024

Screenshot 2023-04-01 at 09 37 34

Hi Houyun,

Is it difficult to add the feature of the solid and dashed lines to make a difference between the positive or negative mantel test relationships, as shown above?

Best,

Bing

from linket.

Hy4m avatar Hy4m commented on August 25, 2024

This part is the same as pure ggplot2, you need to map the linetype to mantel's r and then adjust it using scale_linetype_manual().

Here's an example:

library(linkET)
library(ggplot2)
library(dplyr)
data("varechem", package = "vegan")
data("varespec", package = "vegan")

mantel <- mantel_test(varespec, varechem,
                      spec_select = list(Spec01 = 1:7,
                                         Spec02 = 8:18,
                                         Spec03 = 19:37,
                                         Spec04 = 38:44)) %>% 
  mutate(rd = cut(r, breaks = c(-Inf, 0.2, 0.4, Inf),
                  labels = c("< 0.2", "0.2 - 0.4", ">= 0.4")),
         pd = cut(p, breaks = c(-Inf, 0.01, 0.05, Inf),
                  labels = c("< 0.01", "0.01 - 0.05", ">= 0.05")))

qcorrplot(correlate(varechem), type = "lower", diag = FALSE) +
  geom_square() +
  geom_couple(aes(colour = pd, size = rd, linetype = r > 0), 
              data = mantel, 
              curvature = nice_curvature()) +
  scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdBu")) +
  scale_size_manual(values = c(0.5, 1, 2)) +
  scale_colour_manual(values = color_pal(3)) +
  scale_linetype_manual(values = c("TRUE" = "solid", "FALSE" = "dashed")) +
  guides(size = guide_legend(title = "Mantel's r",
                             override.aes = list(colour = "grey35"), 
                             order = 2),
         colour = guide_legend(title = "Mantel's p", 
                               override.aes = list(size = 3), 
                               order = 1),
         fill = guide_colorbar(title = "Pearson's r", order = 3))

from linket.

B-1991-ing avatar B-1991-ing commented on August 25, 2024

Screenshot 2023-04-02 at 11 48 39

image

Yeah, thank you Houyun. I also added the code on making my own plots. But, in both figures, why all significant Mantel's r are positive related lines and only some non-significant Mantel's r represent negative relationship? Is it a bit strange?

Best,

Bing

from linket.

Hy4m avatar Hy4m commented on August 25, 2024

Whether the result is reasonable or not requires professional knowledge to judge.😂

from linket.

Related Issues (20)

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.