qbarplot.stacked.from.wide.df | R Documentation |
Draw and save a stacked barplot for each row of a dataframe.
qbarplot.stacked.from.wide.df(
df,
x = "Samples",
y = "Fraction",
z = "Category",
color = 1,
label = NULL,
also.pdf = FALSE,
save.obj = FALSE,
ext = MarkdownHelpers::ww.set.file.extension(default = "png", also_pdf = also.pdf),
plotname = FixPlotName(substitute(df)),
subtitle = NULL,
suffix = NULL,
caption = suffix,
filename = NULL,
scale = TRUE,
plot = TRUE,
save = TRUE,
mdlink = MarkdownHelpers::unless.specified("b.mdlink", def = FALSE),
hline = FALSE,
filtercol = 1,
palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb",
"uchicago")[4],
xlab.angle = 45,
xlab = x,
logY = FALSE,
annotation_logticks_Y = logY,
hide.legend = FALSE,
max.names = 50,
limitsize = FALSE,
grid = "y",
max.categ = 10,
w = qqqAxisLength(df, factor = 0.7),
h = 5,
...
)
df |
The variable to plot. |
x |
Colname to split along X axis. Default: "Samples". |
y |
Colname to count along y axis. Default: "Fraction". |
z |
Colname to split along Y axis. Default: "Category. |
color |
Color (split) by along Y. |
label |
label |
also.pdf |
Save plot in both png and pdf formats. |
save.obj |
Save the ggplot object to a file. Default: FALSE. |
ext |
File extension (.pdf / .png). |
plotname |
The title of the plot and the name of the file (unless specified in |
subtitle |
Optional subtitle text added below the title. Default is NULL. |
suffix |
Optional suffix added to the filename. Default is NULL. |
caption |
Optional text added to bottom right corner of the plot. Default = suffix |
filename |
Manually provided filename (optional). Default: parse from |
scale |
Scale the y axis. Default: TRUE. |
plot |
Display the plot. |
save |
Save the plot into a file. |
mdlink |
Insert a .pdf and a .png image link in the markdown report, set by "path_of_report". |
hline |
Draw a horizontal line on the plot. |
filtercol |
Color bars below / above the threshold with red / green. Define the direction by -1 or 1. Takes effect if "*line" is defined. |
palette_use |
GGpubr Color palette to use. |
xlab.angle |
Rotate X-axis labels by N degree. Default: 90 |
xlab |
X-axis label. Default: |
logY |
Make Y axis log10-scale. |
annotation_logticks_Y |
Logical indicating whether to add annotation logticks on Y-axis. Default follows the value of |
hide.legend |
hide legend |
max.names |
The maximum number of names still to be shown on the axis. |
limitsize |
limitsize |
grid |
Character indicating the axis to add gridlines. Options are 'x', 'y', or 'xy'. Default is 'y'. |
max.categ |
The maximum allowed number of unique categories. |
w |
Width of the plot. |
h |
Height of the plot. |
... |
Pass any other parameter of the corresponding plotting function(most of them should work). |
# Example of wide-format data for stacked bar plot
df.SingletSplit <- tibble::tibble(
doublet = c(0.027886224, 0.007699141, 0.003704390, 0.003205128),
singlet = c(0.9686280, 0.9872668, 0.9925912, 0.9119822),
unassigned = c(0.0034857780, 0.0050340539, 0.0037043897, 0.0848126233)
)
rownames(df.SingletSplit) <- c("sc06.692", "sc06.693", "sc08.325", "sc08.327")
# Create the stacked bar plot using the new qbarplot.df2 function
qbarplot.stacked.from.wide.df(df.SingletSplit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.