Body: <p>I have a table of fold change shifts for two different groups. Some of them are upregulated, others are downregulated. I wonder if it is ok to subset only positive values and to boxplot them to show only upregulated genes and vice versa?</p>
  <pre><code>     Gene   REDmean   GRNmean
  1    gen1   4.918239  4.547266 
  2    gen2   3.635476  3.447484 
  3    gen3   -3.759263 -3.283889 
  4    gen4   3.962326  2.818917 
  5    gen5   -3.474217 -3.123105 
  6    gen6   3.653160  2.907355
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-31T02:08:07.617Z
Comments.Text: Try again, use separate boxplot columns i.e. upregulated vs. downregulatated that are created using a dataframe e.g. pandas. For pandas use a filter to create a new column of 'UpDown', i.e. a boolean of upregulated or downregulated, and then use the groupby('UpDown') command. Send that into matplotlib boxplot function and it should work. The 'Gene' column needs removing (I think). My pandas is too rusty to knock out the code. Someone here might show a solution in R, but if you attempt a pandas approach and post it, someone will probably run with it.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-31T02:21:27.713Z
Comments.Text: Basically you'll reorder and pivot the data using a dataframe using the up- down-regulated filter (I'm not sure if 'pivot' is a correct term). What I don't like is your use of the word 'mean', for the real thing you need the raw data ... but this would be cool for creating the filter. "'Gene' column needs removing" well thats a bad idea (thats your results), but for the plot it will cause it to fall over if its dragged in on a dataframe - thats what I meant in the comment above.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-31T14:05:15.697Z
Comments.Text: Thank you. As I have asked in my previous posts I am still thinking if this is a valid approach to compare the mean fold change between two groups. And once again, I wonder if I can compare their fold changes (FC), say, for gene1 in RED group I have 5 for control and 25 for treated sample and in GRN group (for the same gene1) I do have 2 for control and 10 for treated. For REDs I do have a 5X FC increase (from 5 to 25) and for GRN it is also 5X (from 2 to 10). For me there is no difference between RED and GRN groups based on gene1.
Comments.UserDisplayName: Mark
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-31T14:05:20.867Z
Comments.Text: The idea of the 'REDmean' and 'GRNmean' is that I have multiple samples, so I have taken a mean control vs treatment ratio (that are presented in a table above). The question is if I have the right to do that, and if yes - can I distinguish them just by separating negative FC from positive?
Comments.UserDisplayName: Mark
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-31T14:53:49.213Z
Comments.Text: AS A PLOT - I have no problem. As a statistical test ... I think we covered the stats and I personally would not favour change-fold ... but if is an approach to standardisation (its a separate question) that is different. However, others might agree with you, i.e. a test on change-fold. The operation you are describing here to manipulate and plot is a serious question that requires formal code in R or Python. "Try again" ... sorry this was a personal comment, my first comment got deleted so I "tried again", this could be misinterpreted however.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-31T14:56:09.987Z
Comments.Text: It is good to keep questions distinct, because this question over a very large dataset isn't trivial, i.e. to provide the code that will perform the pivot. I honestly can't remember fully how to do it without looking it up (I've done similar things in the past).
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-31T20:25:30.680Z
Comments.Text: I'll be working on pandas again shortly (couple of weeks). I'll be able to answer the question then if someone doesn't do this before.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-31T21:12:38.567Z
Comments.Text: Great! Thanks a lot for the help
Comments.UserDisplayName: Mark
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-04-01T11:10:34.207Z
Comments.Text: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/135213/discussion-between-mark-and-m).
Comments.UserDisplayName: Mark
Tags: <differential-expression>
Title: How can I separate upregulated genes from downregulated on a boxplot?
ThreadText: # How can I separate upregulated genes from downregulated on a boxplot?
  
  (Asked by: username_0 on 2022-03-30)
  
  I have a table of fold change shifts for two different groups. Some of them are upregulated, others are downregulated. I wonder if it is ok to subset only positive values and to boxplot them to show only upregulated genes and vice versa?
  
  ```
       Gene   REDmean   GRNmean
  1    gen1   4.918239  4.547266 
  2    gen2   3.635476  3.447484 
  3    gen3   -3.759263 -3.283889 
  4    gen4   3.962326  2.818917 
  5    gen5   -3.474217 -3.123105 
  6    gen6   3.653160  2.907355
  
  ```
  
  **Tags:** differential-expression
  
  > **Comments:**
  > **username_1**: Try again, use separate boxplot columns i.e. upregulated vs. downregulatated that are created using a dataframe e.g. pandas. For pandas use a filter to create a new column of 'UpDown', i.e. a boolean of upregulated or downregulated, and then use the groupby('UpDown') command. Send that into matplotlib boxplot function and it should work. The 'Gene' column needs removing (I think). My pandas is too rusty to knock out the code. Someone here might show a solution in R, but if you attempt a pandas approach and post it, someone will probably run with it.  
  > **username_1**: Basically you'll reorder and pivot the data using a dataframe using the up- down-regulated filter (I'm not sure if 'pivot' is a correct term). What I don't like is your use of the word 'mean', for the real thing you need the raw data ... but this would be cool for creating the filter. "'Gene' column needs removing" well thats a bad idea (thats your results), but for the plot it will cause it to fall over if its dragged in on a dataframe - thats what I meant in the comment above.  
  > **username_0**: Thank you. As I have asked in my previous posts I am still thinking if this is a valid approach to compare the mean fold change between two groups. And once again, I wonder if I can compare their fold changes (FC), say, for gene1 in RED group I have 5 for control and 25 for treated sample and in GRN group (for the same gene1) I do have 2 for control and 10 for treated. For REDs I do have a 5X FC increase (from 5 to 25) and for GRN it is also 5X (from 2 to 10). For me there is no difference between RED and GRN groups based on gene1.  
  > **username_0**: The idea of the 'REDmean' and 'GRNmean' is that I have multiple samples, so I have taken a mean control vs treatment ratio (that are presented in a table above). The question is if I have the right to do that, and if yes - can I distinguish them just by separating negative FC from positive?  
  > **username_1**: AS A PLOT - I have no problem. As a statistical test ... I think we covered the stats and I personally would not favour change-fold ... but if is an approach to standardisation (its a separate question) that is different. However, others might agree with you, i.e. a test on change-fold. The operation you are describing here to manipulate and plot is a serious question that requires formal code in R or Python. "Try again" ... sorry this was a personal comment, my first comment got deleted so I "tried again", this could be misinterpreted however.  
  > **username_1**: It is good to keep questions distinct, because this question over a very large dataset isn't trivial, i.e. to provide the code that will perform the pivot. I honestly can't remember fully how to do it without looking it up (I've done similar things in the past).  
  > **username_1**: I'll be working on pandas again shortly (couple of weeks). I'll be able to answer the question then if someone doesn't do this before.  
  > **username_0**: Great! Thanks a lot for the help  
  > **username_0**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/135213/discussion-between-mark-and-m).  
  
  ---
  
  ## 0 answers
  
  