This repository was archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Doc: Graphical Output
kmorrisongr edited this page Feb 17, 2020
·
1 revision
fcgo_boxplot(fc, to_box, results_dir, flags, gopts, seed=1337)
- Generate boxplots for a subset of features in an Fc Array data frame, separated out by group membership. Plots both boxes and whiskers and jitter plot of the points. Supports more than 2 groups. Resultant plots will live in a pdf, and be saved in results_dir.
- @param fc The Fc Array data frame
- @param to_box A vector of strings of feature names that you wish to generate boxplots for.
- @param results_dir Where you want your results to be saved.
- @param flags A list of analysis booleans. Must have specified the subparameters:
- flags$do_same_range Do you want all boxplots to have the same y-limits?
- flags$nicer_legend Do you want a nicer legend? Currently applies only to the hardcoded case of RV144, where the binning generates groups that are "yes" and "no". If this flag is TRUE, these get replaced in the plot legends with "Infected" and "Uninfected".
- @param gopts A list of graphical options. Must have specified the subparameters, and then the subsequent optional parameters:
- gopts$bpar_mar The margins for the plots. Sensible starting place is c(5.1, 4.1, 4.1, 4).
- gopts$jplot_group_cols The group colors for the jitter plot points that get drawn on top of the boxes. Should be the same length as unique(fc$group) (i.e. the number of groups you have).
- gopts$bplot_group_cols The same as jplot_group_cols, but for the boxes themselves. Will need to be slightly different if you want points to show up. If one of jplot_group_cols is black, for example, the corresponding bplot_group_cols should be white. Experiment to get it right.
- gopts$box_legend_inset The inset for the legend in the boxplots. Sensible starting place is c(-0.40, 0).
- gopts$pdf_name_suffix If specified, will change the output pdf name from "group1_group2_boxplots.pdf" to "group1_group2_[pdf_name_suffix]_boxplots.pdf".
- gopts$main If specified, sets the title of all the boxplots to the provided string. Else, the name of the feature is used.
- gopts$ylab If specified, sets the title of all boxplots to the provided string. Else, "MFI" will be used.
- @return Nothing! Just outputs plots.
- @examples
flags = list() # add some things
gopts = list() # add some more things
# produce a pdf containing boxplots of all IgG3 features, with points colored by fc$group membership
fcgo_boxplot(fc, colnames(fc)[grepl("IgG3", colnames(fc), fixed=TRUE)], "/home/me/results/", flags, gopts)fcgo_get_prop(feat, prop_cats, prop_quals)
- Get properties (shape, color) for a feature (case-insensitive) from the graphical presets you've specified.
- @param feat The feature string you want to get something for. Case-insensitive. Matching is determined by substrings, so if you want something to be separated out (say, IgG subclasses) while calling this multiple times, put the subclasses first.
- @param prop_cats The categories you have split features into.
- @param prop_quals The shape, color, etc. you are querying into.
- @return A singular value from prop_quals corresponding to which entry in prop_cats feat corresponds to. If no match is found, the last entry in prop_quals is returned (useful for an "other" category if you don't want colors, etc. for every single type of feature).
- @examples
gopts$reag_cats = c("IgG", "FcgRIIa", "FcgRIIb", "FcgRIIIa", "FcgRIIIb")
# orchid is for anything that's not in the above categories
gopts$reag_cols = c("black", "forestgreen", "purple", "gold", "orange", "orchid")
feats = c("IgG3.gp120", "FcgRIIa.gp41", "FcgRIIIa.gp70.V1.V2", "C1q.aHuIgG")
(colors = as.vector(sapply(feats, fcgo_get_prop, gopts$reag_cats, gopts$reag_cols)))
[1] "black" "forestgreen" "gold" "orchid"
# Subclasses
gopts$reag_cats = c("IgG1", "IgG2", "IgG3", "IgG4", "C1q", "IgG")
gopts$reag_cols = c("blue", "pink", "turquoise1", "saddlebrown", "green", "black", "orchid")
feats = c("IgG3.gp120", "IgG.gp41.MN", "Ig2.Vif", "FcgRIIa.gp41", "FcgRIIIa.gp70.V1.V2", "C1q.aHuIgG")
(colors = as.vector(sapply(feats, fcgo_get_prop, gopts$reag_cats, gopts$reag_cols)))
[1] "black" "turquoise1" "black" "pink" "orchid" "orchid" "green"fcgo_l10_pplot(p_vals, pdf_name, main, line_method, gopts, pt_colors, pt_shapes, ylim=NULL)
- Plots p-values after -log10 transforming them. This makes a plot where points higher up on the y-axis are lower p-values. Points are colored by detection reagant and shaped by antigen being detected.
- @param p_vals A vector of p-values.
- @param pdf_name The name of the output file where the plot will be saved. Should be a full file path.
- @param main The title of the plot.
- @param line_method A string indicating the method you want to use to draw the arbitrary cutoff line. "bonferroni" (for p < 0.05), "fdr" (for q < 0.2), and "raw" (just -log10(0.05)) are supported.
- @param gopts A list of graphical options. Must have specified the subparameters:
- gopts$ppar_mar The margins for this plot. See ?par for more info. Default is c(5.1, 4.1, 4.1, 6).
- gopts$reag_legend_inset The inset for the legend relative to the plot.
- gopts$reag_cats The categories for your detection reagants.
- gopts$reag_cols The colors for the detection reagant categories.
- gopts$ant_shapes The shapes for the antigens being detected.
- @param pt_colors Colors for each point in p_vals. These should be generated from gopts$reag_cols. See ?fcgo_get_prop for an example of how to generate this.
- @param pt_shapes Shapes for each point in p_vals. These should be generated from gopts$ant_shapes. See ?fcgo_get_prop for an example of how to generate this.
- @param ylim An optional parameter for setting the y-limits of the plot.
- @return Nothing!
fcgo_volcano_plot(foch, p_vals, line_method, main, xlab, ylab, gopts, pt_colors, pt_shapes)
- Plots p-values versus fold change values. Points are colored by detection reagant and shaped by antigen being detected.
- @param foch A vector of fold change values.
- @param p_vals A vector of p-values.
- @param line_method A string indicating the method you want to use to draw the arbitrary cutoff line. "bonferroni" (for p < 0.05), "fdr" (for q < 0.2), and "raw" (just -log10(0.05)) are supported.
- @param main The title of the plot.
- @param xlab The label for the x-axis.
- @param ylab The label for the y-axis.
- @param gopts A list of graphical options. Must have specified the subparameters:
- gopts$volc_xlim The x-limits for the volcano plot.
- gopts$volc_ylim The y-limits for the volcano plot.
- gopts$reag_legend_inset The inset for the legend relative to the plot. Reasonable place to start is c(-0.18, 0).
- gopts$reag_cats The categories for your detection reagants.
- gopts$reag_cols The colors for the detection reagant categories.
- gopts$ant_shapes The shapes for the antigens being detected.
- @param pt_colors Colors for each point in p_vals. These should be generated from gopts$reag_cols. See ?fcgo_get_prop for an example of how to generate this.
- @param pt_shapes Shapes for each point in p_vals. These should be generated from gopts$ant_shapes. See ?fcgo_get_prop for an example of how to generate this.
- @return Nothing!
fcgo_plot_dimred(fc, dims, pdf_name, main, legend, group_cols, cols, shapes)
- Plot the results of fcdr_dimred.
- @param fc The Fc Array data frame that resulted from fcdr_dimred.
- @param dims The number of dimensions used for fcdr_dimred.
- @param pdf_name The name of the output file where the plot will be saved. Should be a full file path.
- @param main The title of the plot.
- @param legend The text that will fill in the legend. Should be a vector of strings.
- @param group_cols The colors for the legend text. Should be a vector of strings of the same length as legend.
- @param cols The colors for each of the points in the plot. Should be of the same length as the number of points plotted (i.e. nrow(fc)). Should probably be the same colors as group_cols if you want your plot to be interpretable.
- @param shapes The shapes for each of the points in the plot. Should be of the same length as the number of points plotted (i.e. nrow(fc)).
- @return Nothing!
- @examples
fc_tnse = fcdr_dimred(fc, "tsne", dims=2)
group_cols = c("blue", "red")
cols = sapply(fc$group, function(x){ if (x == "PLACEBO"){ return("blue") } else { return("red") } })
shapes = sapply(fc$group, function(x){ if (x == "PLACEBO"){ return(21) } else { return(22) } })
fcgo_plot_dimred(fc_tsne, 2, "results/tsne_plot.pdf", "tSNE Components for PLAC/VACC", c("PLAC", "VACC"), group_cols, cols, shapes)fcgo_fcs_volcano(fcs, master_fochs, master_p_vals, results_dir, adj_method, line_method, gopts)
- Documentation WIP
- gopts defaults: volc_xlim=c(-2.5,2.5), volc_ylim=c(0,8)), volc_legend_inset=c(-0.17,0)
- fcs must be from fcmu_fcs_combs(fc, "group")