RC_kernel: RC_kernel

Description Usage Arguments Details Value Author(s) References Examples

View source: R/RC_kernel.R

Description

Plot a kernel graph do check the value distribution in your data.

Usage

1
RC_kernel(Data_melt, color1, ...)

Arguments

Data_melt

A melted dataframe from your Data and Design. You should use the RC_melt function to create this or directly the reshape2::melt function.

color1

A feature from your Design to split the different shade of your distribution.

vertical1

A value to plot a vertical line at the desired threshold.

log2

if TRUE then the value in the column value of the melted dataframe are log2ged. Set to TRUE by default.

Details

PLot a kenel density graph after performing a log2+1 transfo to check the value distribution. In RNA-Seq this is useful to check the background noise and define a threshold value. Using the color1 option let you see if there are different distribution related to a specific feature. This not desired if yes ...

Value

return a graph object.

Author(s)

Benjamin Vittrant

References

https://en.wikipedia.org/wiki/Kernel_density_estimation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
RC_kernel = function(Data_melt, color1, vertical1, Title, log2 = TRUE){
  # Log2 the value
  if(log2 == TRUE){Data_melt$value = log2(Data_melt$value+1) }
  # kernel plot
  p = ggplot(Data_melt, aes(value)) +
    geom_density(aes_string(fill = color1), alpha = 0.1) +
    theme(legend.position="right", legend.text=element_text(size=5)) +
    geom_vline(xintercept = vertical1, linetype="dashed", size = 0.3) +
    labs(x = Title)

  # The function will return:
  return(p)
}

bvittrant/RCommon documentation built on May 4, 2020, 3:04 p.m.