Order x axis by one then another parameter and plot in ggplot (phyloseq)Change the order of a discrete x scaleplotting melted data.frame with ggplot, does aes(x) need to be a factor?Sorting data on X axisReorder label y axis in ggplotline and point curve using factors in ggplot?Draw lines between two different (“grid.arranged”) plotsggplot/plot in Shiny not workingChange order in which ggplot plots the Y axis variablesPlotting `ggplot` sorted on specific valueggplot sorting axis with flipped coordinates and faceted graphResidual plot with ggplot with X-axis as “ranked” residuals
What does "Scientists rise up against statistical significance" mean? (Comment in Nature)
Animation: customize bounce interpolation
Identifying "long and narrow" polygons in with PostGIS
What the heck is gets(stdin) on site coderbyte?
Ways of geometrical multiplication
In One Punch Man, is King actually weak?
How to get directions in deep space?
Why would five hundred and five be same as one?
How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?
Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?
Showing mass murder in a kid's book
Limit max CPU usage SQL SERVER with WSRM
Isometric embedding of a genus g surface
How were servants to the Kaiser of Imperial Germany treated and where may I find more information on them
Proving an identity involving cross products and coplanar vectors
Giving feedback to someone without sounding prejudiced
Deciphering cause of death?
Is there a way to play vibrato on the piano?
Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?
Do I have to know the General Relativity theory to understand the concept of inertial frame?
ContourPlot — How do I color by contour curvature?
Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?
PTIJ: Which Dr. Seuss books should one obtain?
Why is participating in the European Parliamentary elections used as a threat?
Order x axis by one then another parameter and plot in ggplot (phyloseq)
Change the order of a discrete x scaleplotting melted data.frame with ggplot, does aes(x) need to be a factor?Sorting data on X axisReorder label y axis in ggplotline and point curve using factors in ggplot?Draw lines between two different (“grid.arranged”) plotsggplot/plot in Shiny not workingChange order in which ggplot plots the Y axis variablesPlotting `ggplot` sorted on specific valueggplot sorting axis with flipped coordinates and faceted graphResidual plot with ggplot with X-axis as “ranked” residuals
I am trying to graph my phyloseq/deseq2 data output (Log2FoldChange on y and Species name on x) in ggplot and I would like to be able to order them by autotrophs and heterotrophs as well as max-min value. I have a column I added into the Taxa file named "Trophic".
Taxa file snippet
The pipeline turns the phyloseq object into a deseq object, and that is where Log2FoldChange comes in.
deseq output snippet
Then they're combined, which is what I am working with.
(Here is the tutorial if you need more)
I have this code, which I think orders the species by highest to lowest Log2FoldChange and comes out with a graph like this.
x = tapply(sigtab$log2FoldChange, sigtab$Species, function(x) max(x))
x = sort(x, TRUE)
sigtab$Species = factor(as.character(sigtab$Species), levels=names(x)
However, I am not exactly sure how to modify this in order to have them sorted first by trophic status and then by species and then plotted as such.
I would basically like to be able to have two "sides" of the same graph (auto then hetero), both ordered from max value to min value of Log2FoldChange.
Could anyone please help me figure this out?
r sorting ggplot2 phyloseq
add a comment |
I am trying to graph my phyloseq/deseq2 data output (Log2FoldChange on y and Species name on x) in ggplot and I would like to be able to order them by autotrophs and heterotrophs as well as max-min value. I have a column I added into the Taxa file named "Trophic".
Taxa file snippet
The pipeline turns the phyloseq object into a deseq object, and that is where Log2FoldChange comes in.
deseq output snippet
Then they're combined, which is what I am working with.
(Here is the tutorial if you need more)
I have this code, which I think orders the species by highest to lowest Log2FoldChange and comes out with a graph like this.
x = tapply(sigtab$log2FoldChange, sigtab$Species, function(x) max(x))
x = sort(x, TRUE)
sigtab$Species = factor(as.character(sigtab$Species), levels=names(x)
However, I am not exactly sure how to modify this in order to have them sorted first by trophic status and then by species and then plotted as such.
I would basically like to be able to have two "sides" of the same graph (auto then hetero), both ordered from max value to min value of Log2FoldChange.
Could anyone please help me figure this out?
r sorting ggplot2 phyloseq
You can arrange in order withdplyr::arrange()
and you can specify whether you want it in desc order otherwise it will be ascending by default.arrange(data, first, desc(second))
etc.
– Croote
Mar 7 at 22:26
Oh marvelous! So that worked and I was able to correctly order my actual data frame, but when I plot it the species names are still in alphabetical rather than being in the order I just put them in. Is there a special thing I would need to add in order to keep it like that (as in non-alphabetical) for the graph?
– Megan Ladds
Mar 8 at 3:34
See Here for more discussion on reordering factors for plotting
– Croote
Mar 8 at 6:00
1
Thank you so much for your help. I was able to fix the graph using thissigtab<-arrange (sigtab, Trophic, desc(log2FoldChange)) sigtab$Species <- factor(sigtab$Species, levels = sigtab$Species)
– Megan Ladds
Mar 11 at 18:58
add a comment |
I am trying to graph my phyloseq/deseq2 data output (Log2FoldChange on y and Species name on x) in ggplot and I would like to be able to order them by autotrophs and heterotrophs as well as max-min value. I have a column I added into the Taxa file named "Trophic".
Taxa file snippet
The pipeline turns the phyloseq object into a deseq object, and that is where Log2FoldChange comes in.
deseq output snippet
Then they're combined, which is what I am working with.
(Here is the tutorial if you need more)
I have this code, which I think orders the species by highest to lowest Log2FoldChange and comes out with a graph like this.
x = tapply(sigtab$log2FoldChange, sigtab$Species, function(x) max(x))
x = sort(x, TRUE)
sigtab$Species = factor(as.character(sigtab$Species), levels=names(x)
However, I am not exactly sure how to modify this in order to have them sorted first by trophic status and then by species and then plotted as such.
I would basically like to be able to have two "sides" of the same graph (auto then hetero), both ordered from max value to min value of Log2FoldChange.
Could anyone please help me figure this out?
r sorting ggplot2 phyloseq
I am trying to graph my phyloseq/deseq2 data output (Log2FoldChange on y and Species name on x) in ggplot and I would like to be able to order them by autotrophs and heterotrophs as well as max-min value. I have a column I added into the Taxa file named "Trophic".
Taxa file snippet
The pipeline turns the phyloseq object into a deseq object, and that is where Log2FoldChange comes in.
deseq output snippet
Then they're combined, which is what I am working with.
(Here is the tutorial if you need more)
I have this code, which I think orders the species by highest to lowest Log2FoldChange and comes out with a graph like this.
x = tapply(sigtab$log2FoldChange, sigtab$Species, function(x) max(x))
x = sort(x, TRUE)
sigtab$Species = factor(as.character(sigtab$Species), levels=names(x)
However, I am not exactly sure how to modify this in order to have them sorted first by trophic status and then by species and then plotted as such.
I would basically like to be able to have two "sides" of the same graph (auto then hetero), both ordered from max value to min value of Log2FoldChange.
Could anyone please help me figure this out?
r sorting ggplot2 phyloseq
r sorting ggplot2 phyloseq
edited Mar 8 at 4:41
Pikachu the Purple Wizard
2,02761329
2,02761329
asked Mar 7 at 22:03
Megan LaddsMegan Ladds
1
1
You can arrange in order withdplyr::arrange()
and you can specify whether you want it in desc order otherwise it will be ascending by default.arrange(data, first, desc(second))
etc.
– Croote
Mar 7 at 22:26
Oh marvelous! So that worked and I was able to correctly order my actual data frame, but when I plot it the species names are still in alphabetical rather than being in the order I just put them in. Is there a special thing I would need to add in order to keep it like that (as in non-alphabetical) for the graph?
– Megan Ladds
Mar 8 at 3:34
See Here for more discussion on reordering factors for plotting
– Croote
Mar 8 at 6:00
1
Thank you so much for your help. I was able to fix the graph using thissigtab<-arrange (sigtab, Trophic, desc(log2FoldChange)) sigtab$Species <- factor(sigtab$Species, levels = sigtab$Species)
– Megan Ladds
Mar 11 at 18:58
add a comment |
You can arrange in order withdplyr::arrange()
and you can specify whether you want it in desc order otherwise it will be ascending by default.arrange(data, first, desc(second))
etc.
– Croote
Mar 7 at 22:26
Oh marvelous! So that worked and I was able to correctly order my actual data frame, but when I plot it the species names are still in alphabetical rather than being in the order I just put them in. Is there a special thing I would need to add in order to keep it like that (as in non-alphabetical) for the graph?
– Megan Ladds
Mar 8 at 3:34
See Here for more discussion on reordering factors for plotting
– Croote
Mar 8 at 6:00
1
Thank you so much for your help. I was able to fix the graph using thissigtab<-arrange (sigtab, Trophic, desc(log2FoldChange)) sigtab$Species <- factor(sigtab$Species, levels = sigtab$Species)
– Megan Ladds
Mar 11 at 18:58
You can arrange in order with
dplyr::arrange()
and you can specify whether you want it in desc order otherwise it will be ascending by default. arrange(data, first, desc(second))
etc.– Croote
Mar 7 at 22:26
You can arrange in order with
dplyr::arrange()
and you can specify whether you want it in desc order otherwise it will be ascending by default. arrange(data, first, desc(second))
etc.– Croote
Mar 7 at 22:26
Oh marvelous! So that worked and I was able to correctly order my actual data frame, but when I plot it the species names are still in alphabetical rather than being in the order I just put them in. Is there a special thing I would need to add in order to keep it like that (as in non-alphabetical) for the graph?
– Megan Ladds
Mar 8 at 3:34
Oh marvelous! So that worked and I was able to correctly order my actual data frame, but when I plot it the species names are still in alphabetical rather than being in the order I just put them in. Is there a special thing I would need to add in order to keep it like that (as in non-alphabetical) for the graph?
– Megan Ladds
Mar 8 at 3:34
See Here for more discussion on reordering factors for plotting
– Croote
Mar 8 at 6:00
See Here for more discussion on reordering factors for plotting
– Croote
Mar 8 at 6:00
1
1
Thank you so much for your help. I was able to fix the graph using this
sigtab<-arrange (sigtab, Trophic, desc(log2FoldChange)) sigtab$Species <- factor(sigtab$Species, levels = sigtab$Species)
– Megan Ladds
Mar 11 at 18:58
Thank you so much for your help. I was able to fix the graph using this
sigtab<-arrange (sigtab, Trophic, desc(log2FoldChange)) sigtab$Species <- factor(sigtab$Species, levels = sigtab$Species)
– Megan Ladds
Mar 11 at 18:58
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053515%2forder-x-axis-by-one-then-another-parameter-and-plot-in-ggplot-phyloseq%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053515%2forder-x-axis-by-one-then-another-parameter-and-plot-in-ggplot-phyloseq%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can arrange in order with
dplyr::arrange()
and you can specify whether you want it in desc order otherwise it will be ascending by default.arrange(data, first, desc(second))
etc.– Croote
Mar 7 at 22:26
Oh marvelous! So that worked and I was able to correctly order my actual data frame, but when I plot it the species names are still in alphabetical rather than being in the order I just put them in. Is there a special thing I would need to add in order to keep it like that (as in non-alphabetical) for the graph?
– Megan Ladds
Mar 8 at 3:34
See Here for more discussion on reordering factors for plotting
– Croote
Mar 8 at 6:00
1
Thank you so much for your help. I was able to fix the graph using this
sigtab<-arrange (sigtab, Trophic, desc(log2FoldChange)) sigtab$Species <- factor(sigtab$Species, levels = sigtab$Species)
– Megan Ladds
Mar 11 at 18:58