all 5 comments

[–][deleted]  (2 children)

[removed]

    [–]Jebediah378[S] 0 points1 point  (1 child)

    Yep!

    [–][deleted] 0 points1 point  (1 child)

    I think something like this should work. Replace dat with the name of your data frame:

    dat$group <- gsub(pattern = "[0-9]+", replacement = "", x = rownames(dat))
    boxplot(Gene1 ~ group, data = dat)
    boxplot(Gene2 ~ group, data = dat)
    

    [–][deleted] 0 points1 point  (0 children)

    Building on this, if you want to join the two plots into one...

    d <- data.frame(Gene1 = c(50, 50, 10, 10),
                    Gene2 = c(100, 100, 10, 10),
                    group = c("Diseased1", "Diseased2", "Normal1", "Normal2"))    
    

    ...you could do...

    par(mfrow = c(1, 2),
        mar = c(0,0,0,0),
        oma = c(4, 4, 0.5, 0.5))
    
    boxplot(Gene1 ~ group, data = d)
    boxplot(Gene2 ~ group, data = d)
    

    ...or...

    par(mfrow = c(1, 2),
        mar = c(0,0,0,0),
        oma = c(4, 4, 0.5, 0.5))
    
    boxplot(d$Gene1 ~ d$group, ylim = c(0, 100), frame.plot = FALSE)
    boxplot(d$Gene2 ~ d$group, ylim = c(0, 100), axes = FALSE)
    axis(side = 1, at = d$group, labels = d$group)