Question: How can i make some bloxplots from a count table?
0
gravatar for sanchi.andrea
2.1 years ago by
sanchi.andrea0 wrote:

enter image description hereHi there, I have a count table in a .txt file that has six columns as follows:

Gene Id WT_1 WT_2 WT_3 MUT_1 MUT_2

GENE1 321 5454 6565 564 535 
GENE2 ..... ...... ...... ..... .....

What I would like to do is just boxplot the data like this (see pic). boxplot

Where F1 F2 F3... have to be the name of my genes.

How can i do that?? Thanks in advance

rna-seq • 691 views
ADD COMMENTlink modified 2.1 years ago • written 2.1 years ago by sanchi.andrea0

I have something similar to that but mine is just a count table

Really?

And How to add images to a Biostars post

ADD REPLYlink written 2.1 years ago by WouterDeCoster44k
1
gravatar for cpad0112
2.1 years ago by
cpad011214k
India
cpad011214k wrote:

Follow the dummy code below and pay attention to df1 object structure : @ sanchi.andrea

genes=rep(paste0("F",seq(1,10)),2)
conditions=rep(c("Tumor","Normal"),each=10)
data=matrix(rnorm(2000,10,10),20,10)
library(dplyr)
df1=data.frame("genes"=genes,"conditions"=conditions,data)
library(tidyr)
df2=df1 %>% gather(Samples, Expression,X1:X10, -genes,-conditions)
library(ggplot2)
ggplot(df2, aes(x=conditions,y=Expression, fill=conditions))+
    geom_boxplot()+
    facet_wrap(~genes)

Rplot

ADD COMMENTlink modified 2.1 years ago • written 2.1 years ago by cpad011214k

@cpad0112

Thanks but your code does not shows me any gene names from my list: do you know how to do it? Thanks

ADD REPLYlink written 2.1 years ago by sanchi.andrea0

sanchi.andrea unfortunately I can't simulate your data from data description. It would help if you could post example data with sample names, gene names and other variables (good and bad)

ADD REPLYlink written 2.1 years ago by cpad011214k

Sure, i'll try to past here an example:

geneID  wt_Sample1  wt_Sample2  wt_Sample3  mut_Sample1 mut_Sample2 mut_Sample3
gene1        2201               1579                 1262              2082            2130                  1765
gene2        135                 150                   181              159             128                 134 
gene3       700              377                   247              667                 577             481
gene4     1135              597                        497              1215                1165                    908

tHe variables are wt (good) and mut (bad).

Sorry for the formatting, this is the best I can do. Thanks again

ADD REPLYlink modified 2.1 years ago by WouterDeCoster44k • written 2.1 years ago by sanchi.andrea0

Sorry for the formatting, this is the best I can do. Thanks again

I added markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

ADD REPLYlink written 2.1 years ago by WouterDeCoster44k

thank you very much!

ADD REPLYlink written 2.1 years ago by sanchi.andrea0
library(ggplot2)
library(dplyr)
library(tidyr)
library(stringr)

df1 %>%
    tibble::rownames_to_column("genes") %>%
    gather("sample", "counts", 2:7,-genes) %>%
    mutate("condition" = str_replace(sample, "_.*", "")) %>%
    mutate(., condition = factor(condition, levels = unique(condition))) %>%
    ggplot(aes(condition, counts, fill = condition)) +
    geom_boxplot() +
    facet_wrap(~ genes, scales = "free")

Rplot01

> df1
      wt_Sample1 wt_Sample2 wt_Sample3 mut_Sample1 mut_Sample2 mut_Sample3
gene1       2201       1579       1262        2082        2130        1765
gene2        135        150        181         159         128         134
gene3        700        377        247         667         577         481
gene4       1135        597        497        1215        1165         908
ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by cpad011214k

after running that, i have got this error:

Error in mutate_impl(.data, dots) : Evaluation error: could not find function "str_replace". In addition: Warning message: attributes are not identical across measure variables; they will be dropped

Do you know how to fix it? Thanks

ADD REPLYlink written 2.1 years ago by sanchi.andrea0
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: 2060 users visited in the last hour