Question: Dividing the groups on the same axis using ggplot2
1
gravatar for Leite
20 months ago by
Leite1.1k
São Paulo - Brazil - Unifesp
Leite1.1k wrote:

Initially I asked a question of how to make a dotplot from a list of pathways. I was able to generate the graph, but now I can not make the groups side by side using the pathways of reference.

I do not know if that's how I tabulated my results, or if it's a problem with my code, could anyone help me?

My data

my-data

My code

data <- read.csv("S3.csv", sep =";", header = TRUE, stringsAsFactors = FALSE)
library("ggplot2")
S3<- ggplot(data, aes(x="Groups", y=Pathways, size=DEGs, color=FDR)) + geom_point(alpha = 0.8) + facet_grid(Group ~ .) + theme_classic()
S3
S3 = S3+scale_color_gradient(low = "red2",  high = "mediumblue", space = "Lab", limit = c(0.000000000000000000000000000000000000000000000004, 0.03))
S3+scale_size(range = c(2, 8))
S3

My result

result

How do I want the dotplot look like (Edited image)

S3

Best regards, Leite

dotplot graph ggplot2 R • 977 views
ADD COMMENTlink modified 20 months ago by Prakash1.9k • written 20 months ago by Leite1.1k
1

When pasting data, please consider using text instead of a screenshot. Graphics cannot be copied and pasted into a form where your plot script can be tested.

Using text helps make questions that are easily reproducible and thus easier to answer (and so easier to help you).

ADD REPLYlink written 20 months ago by Alex Reynolds30k

Dear Alex Reynolds, Thanks for the tip, next time I'll put it as indicated.

Best, Leite

ADD REPLYlink written 20 months ago by Leite1.1k

Dear Leite,

I tried your code to generate dot plot, however, I was getting the following error:

Error: At least one layer must contain all faceting variables: Groups. * Plot is missing Groups * Layer 1 is missing Groups

input format in .csv: Pathway DEGs Padj Groups BILE_ACID_METABOLISM 42 0.0009 Upreg COAGULATION 28 0.0163 Upreg

code: data <- read.csv("pathway_dotplot.csv", sep =";", header = TRUE, stringsAsFactors = FALSE) library("ggplot2") dp<- ggplot(data, aes(x="Groups", y=Pathway, size=DEGs, color=Padj)) + geom_point(alpha = 0.8) + facet_wrap(Group ~ .) + theme_classic()

Not sure what I was doing different from yours.

Thanks in advance.

Best regards, Pradeep

ADD REPLYlink written 15 days ago by pradeep.ramagiri0

I think it is showing the error because you have mentioned "Groups" instead of "Group" for x axis.

ggplot(data, aes(x=Group, y=Pathway, size=DEGs, color=Padj)) + 
       geom_point(alpha = 0.8) + 
       facet_wrap(Group ~ .) + 
       theme_classic()
ADD REPLYlink written 15 days ago by Prakash1.9k
5
gravatar for Prakash
20 months ago by
Prakash1.9k
India
Prakash1.9k wrote:

You need to just use facet_wrap(Group ~ .) instead of facet_grid

ADD COMMENTlink modified 20 months ago • written 20 months ago by Prakash1.9k

Dear Prakash

This is exactly what I was looking for. Thank you so much!

Best, Leite

ADD REPLYlink written 20 months ago by Leite1.1k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1795 users visited in the last hour