Closed B-1991-ing closed 1 year ago
I had no problems after the test, and can you tell me what your problem is?
library(linkET)
library(dplyr)
library(ggplot2)
data_o <- read.table(file.choose(), sep="\t", row.names = 1, header = TRUE)
O_e <- read.table(file.choose(), sep="\t", row.names = 1, header = TRUE)
###mantel test
mantel_oms <- mantel_test(data_o, O_e,
spec_select = list(m1 = 1:1,
m2 = 2:2,
m3 = 3:3,
m4 = 4:4,
m5 = 5:5,
m6 = 6:6,
m7 = 7:7,
m8 = 8:8),
spec_dist = dist_func(.FUN = "vegdist",
method = "euclidean")) %>%
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")))
o_plot <- correlate(O_e, engine = "correlation") %>%
as_md_tbl(type = "lower", diag = FALSE) %>%
qcorrplot() +
geom_square() +
geom_mark(
sep = '\n',
size = 3,
sig_level = c(0.05, 0.01, 0.001),
mark = c("*", "**", "***"),
colour = "#000000", only_mark = FALSE) +
scale_fill_gradientn(
colours = colorRampPalette(colors =c("#A6CEE3","white","#ED665D"),space="Lab")(10),
limits = c(-1, 1),
breaks = seq(-1,1,0.5))+
geom_couple(aes(x = .x - 0.2, colour = pd, size = rd, linetype = r > 0),
data = mantel_oms,
curvature = nice_curvature(0.1), label.size =4, nudge_x= 0.2) +
scale_size_manual(values = c(0.5, 1, 2)) +
scale_color_manual(values = c("#d00000", "#fcbf49","#d9d9d9")) +
#scale_color_manual(values = c("#d9d9d9")) +
scale_linetype_manual(values = c("TRUE" = "solid", "FALSE" = "dashed"),
labels = c("Positive", "Negative")) +
theme(axis.text.x.bottom = element_text(angle = 45, hjust = 1, vjust = 1)) +
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 = 4),
linetype = guide_legend(title = "Mantel's r > 0",
override.aes = list(size = 0.5, colour = "darkblue"),
order = 3))
o_plot
Thank you Houyun.
My problem is that all significant relationships are denoted as positive relationship instead of some significant positive relationship and some significant negative relationship. I know I asked once. Sorry for the double asking. Maybe you can close the question.
Best,
Bing
I think it's OK.
Finally, it's better to email me for similar questions rather than an issue, since it's not a question about linkET
package.
Hi Houyun,
I carefully looked into the changing trend of my two matrixes, and not sure my command lines were right. So, could you please help me have a check? I attached my data and code.
data_and_code.zip
Thank you very much.
Best,
Bing