sp_histogram: Generating histogram plot

Description Usage Arguments Value Examples

View source: R/sp_histogram.R

Description

Generating histogram plot

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
sp_histogram(
  data,
  melted = FALSE,
  xvariable = NULL,
  color_variable = NULL,
  color_variable_order = NULL,
  group_variable = NULL,
  group_variable_order = NULL,
  value_scale = 1,
  facet_variable = NULL,
  facet_variable_order = NULL,
  maximum_allowed = Inf,
  yaxis_statistics = "count/sum(count)",
  plot_type = "line",
  binwidth = NULL,
  hist_bar_position = "identity",
  alpha = 0.4,
  yaxis_scale_mode = NULL,
  y_add = 0,
  fill_area = FALSE,
  line_size = 1,
  add_mean_value_vline = FALSE,
  manual_color_vector = "Accent",
  facet_scales = "fixed",
  facet_ncol = NULL,
  facet_nrow = NULL,
  xtics = TRUE,
  ytics = TRUE,
  legend.position = "right",
  xtics_angle = 0,
  manual_xtics_value = NULL,
  manual_xtics_pos = NULL,
  custom_vline_x_position = NULL,
  custom_vline_anno = NULL,
  x_label = NULL,
  y_label = NULL,
  title = "",
  font_path = NULL,
  debug = F,
  extra_ggplot2_cmd = NULL,
  filename = NULL,
  base_font_size = 11,
  ...
)

Arguments

data

Data frame or data file (with header line, the first column will not be treated as the row-names, tab separated)

melted

TRUE for dealing with long format matrix, the program will skip melt preprocess. If input is wide format matrix, this parameter should be set to FALSE.

xvariable

Specify the column name used as Y-axis value (one of column names, should be specified when inputting long format matrix).

color_variable

Specify the column name used as color variable.

color_variable_order

Levels for color variable to set their appearing order. Accept a vector like c('ctcf','h3k27ac') (normally whole or a subset of unique values of one column with order specified).

group_variable

Specify the column name used as group variable.

group_variable_order

Levels for color variable to set their appearing order. Accept a vector like c('ctcf','h3k27ac') (normally whole or a subset of unique values of one column with order specified).

value_scale

Scale value. All values will be divided by supplied one. Default 1.

facet_variable

Wrap plots by given column (one of column names should be specified). This is used to put multiple plot in one picture.

facet_variable_order

Order of facets (to set the appearance order of each subplot). Accept a vector like c('ctcf','h3k27ac') (normally whole or a subset of unique values of one column with order specified).

maximum_allowed

The largest value allowed. Values other than this will be set as this value. Default Inf.

yaxis_statistics

Plot with density or count or frequency in y-axis. Default frequency, accept density, count. When plot_type is both, 'frequency“ will be given here.

plot_type

Plot frequency or density or hist or both frequency and histogram. Default line means frequency accept density_line, hist or both.

binwidth

The value for binwidth`` (like the width of each bin) in geom_density, and binwidthforgeom_histogram'.

hist_bar_position

Position parameter for hist bars. Default identity, accept dodge.

yaxis_scale_mode

Give the following scale_y_log10(), coord_trans(y="log10"), or other legal command for ggplot2 or simply log2 to set the scale way.

y_add

A number to add if log scale is used. Default 0 meaning the minimum non-zero value would be used.

fill_area

Fill the area if TRUE. Default FALSE.

line_size

line size. Default 1. Accept a number.

add_mean_value_vline

Add mean value as vline. Default FALSE, accept TRUE.

facet_scales

Paramter for scales for facet. Default fixed meaning each inner graph use same scale (x,y range), free (variable x, y ranges for each sub-plot), free_x (variable x ranges for each sub-plot), free_y (variable y ranges for each sub-plot).

facet_ncol

The number of columns one want when facet is used. Default NULL.

facet_nrow

The number of rows one want when facet is used. Default NULL.

xtics

Show the X axis.

ytics

Show the Y axis.

legend.position

Position of legend, accept top, bottom, left, right, none or c(0.8,0.8).

xtics_angle

Rotation angle for a-axis. Default 0.

manual_xtics_value

Manually set the values of xtics when manual_xtics_position is specified. Default the content of manual_xtics_position when manual_xtics_position is specified, accept a series of numbers in following format "c(1,2,3,4,5)" or other R code that can generate a vector to set the value of manual xtics.

manual_xtics_pos

Manually set the positions of xtics. Default FALSE, accept a series of numbers in following format "c(1,2,3,4,5)" or other R code that can generate a vector to set the position of manual xtics.

custom_vline_x_position

A vector of coordinates for vertical lines.

custom_vline_anno

Annotation text for each vertical line.

x_label

Xlab label.

y_label

Ylab label.

title

Title of picture.

font_path

Specify font type. Give a path for one font type file like '/etc/fonts/Arial.ttf' or 'HeiArial.ttc'(if in current directory), Default system default.

extra_ggplot2_cmd

Extra ggplot2 commands (currently unsupported)

filename

Output picture to given file.

...

Other parameters given to sp_ggplot_layout

Value

A ggplot2 object

Examples

1
2
3
4
5
6
7
8
9
histogram_test_data <- data.frame(Type = letters[1:2], Value = runif(80))
sp_histogram(data = histogram_test_data, xvariable = "Value", color_variable = "Type",
 plot_type = "both", yaxis_statistics = "count/sum(count)")

## Not run:
input <- "histogram.data"
sp_histogram(data=input, xvariable = "Value", color_variable = "Type",
 plot_type = "both", yaxis_statistics = "count/sum(count)")
## End(Not run)

Tong-Chen/YSX documentation built on Jan. 25, 2021, 2:49 a.m.