3/4/2023 0 Comments Mucommander text overlappingEasy to incorporate in stat_summary: meanminsd <- function ( x ) plot <- baseplot + geom_point ( position = position_dodge ( width = 0.7 ) ) + scale_y_continuous ( trans = 'log10', breaks = c ( 1 : 10 ) ) + stat_summary ( fun.y = "mean", fun.ymin = "meanminsd", fun.ymax = "meanplussd", You can also use other descriptive statistics, for example, mean and standard deviation. Mean_cl_boot is a wrapper of the smean.cl.boot function from the Hmisc package, and uses a bootstrap procedure to obtain cofidence intervals. In our case, it is better to try to make the add regular spaces that preserve the order of experiments in the plot, using position_dodge: plot <- baseplot + geom_point ( position = position_dodge ( width = 0.7 ) ) print ( plot )Ī potential difference between mutantB and mutantC, can be seen better on a log scale, using the scale_y_continous variable: plot <- baseplot + geom_point ( position = position_dodge ( width = 0.7 ) ) + scale_y_continuous ( trans = 'log10', breaks = c ( 1 : 10 ) ) print ( plot )Īdding descriptive statistics, like mean and standard deviation is done like this: plot <- baseplot + geom_point ( position = position_dodge ( width = 0.7 ) ) + scale_y_continuous ( trans = 'log10', breaks = c ( 1 : 10 ) ) + stat_summary ( fun.data = "mean_cl_boot", geom = "errorbar", width = 0.05, colour = "red" ) print ( plot ) This is better, but jittering scatters the dots and does not preserve any order. If we had plenty of replicates, a jittering can be useful, since it scatters the dots and we can see most of them, for example: plot <- baseplot + geom_point ( position = position_jitter ( w = 0.7, h = 0.0 ) ) print ( plot ) We can use the long-format data to make a first version of a plot: require ( ggplot2 ) Loading required package: ggplot2 baseplot <- ggplot ( data = melted, aes ( x = mutant, y = value, color = experiment ) ) print ( baseplot + geom_point ( ) )Īs expected, the dots are overlapping. We will use the first column, containing the identifier for replicated experiments, as the “variable” (see parameter of the melt function): require ( reshape2 ) Loading required package: reshape2 melted <- melt ( data = mydata, id.vars = 1 ) names ( melted ) <- c ( "experiment", "mutant", "value" ) melted $ experiment <- as.factor ( melted $ experiment ) #make sure we have factors print ( melted ) experiment mutant value The numerical values represent the change in the level of a specific RNA in the different mutant conditions, as compared with a wild-type strain: experiment mutantA mutantB mutantCįirst, we convert the data to a “long-form” type, using the reshape2 package. The example data that will be used in the following example consists of four replicate experiments (“exp1” to “exp4”) for three different conditions that were tested (mutant “A” to “C”). In this post, I demonstrate the use of ggplot2 to build informative plots from Q-PCR results. Using bar plots to show Q-PCR results hides part of the information, which is un-necessary.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |