plotBins: Draw plots of gene counts, bin counts, PSI/PIR value,...

Description Usage Arguments Value Author(s) See Also Examples

Description

Creates a plot with gene counts, bin counts, PSI/PIR value, inclusion and exclusion junctions for selected bins and conditions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
  plotBins( counts, 
            as,
            bin, 
            factorsAndValues, 
            targets,
            main            = NULL,
            colors          = c( '#2F7955', '#79552F', '#465579', 
                                 '#A04935', '#752020', '#A07C35') ,
            panelTitleColors = '#000000',
            panelTitleCex   = 1,
            innerMargins    = c( 2.1, 3.1, 1.1, 1.1 ),
            outerMargins    = c( 0, 0, 2.4, 0 ), 
            useBarplots     = NULL,
            barWidth        = 0.9,
            barSpacer       = 0.4,
            las.x           = 2,
            useHCColors     = FALSE,
            legendAtSide    = TRUE,
            outfolder       = NULL,
            outfileType     = c( 'png', 'bmp', 'jpeg', 'tiff', 'pdf')[1],
            deviceOpt       = NULL ) 

Arguments

counts

An object of class ASpliCounts

as

An object of class ASpliAS

bin

A character vector with the names of the bins to be plotted.

factorsAndValues

A list containing the factor and the values for each factor to be plotted. The order of the factors will modify how the conditions are grouped in the plot. factorsAndValues must be a named list, where the name of each element is a factor and the list element itself is a character vector of the values of this factor in the order to be plotted. See examples for more details.

targets

A data frame containing sample, bam files and experimental factor columns

main

Main title of the plot. If NULL the bin name is used as title.

colors

A vector of character colors for lines and bar plots.

panelTitleColors

A vector of character colors for the titles of each plot panel.

panelTitleCex

Character size expansion for panel titles.

innerMargins

A numerical vector of the form c(bottom, left, top, right) which gives the size of each plot panel margins. Defaults to c( 2.1, 3.1, 1.1, 1.1 )

outerMargins

A numerical vector of the form c(bottom, left, top, right) which gives the size of margins. Defaults to c( 0, 0, 2.4, 0 )

useBarplots

A logical value that indicates the type of plot to be used. If TRUE bar plots are used, if FALSE lines are used. If NULL the type is bar plot if there just two conditions and lines if there are more than two conditions.

barWidth

The width of the bars in bar plots. barWidth must be in (0,1] range. Default value is 0.9.

barSpacer

Fraction of barwidth used as spacer between bar plot groups. Defaule value is 0.4.

las.x

Text orientation of x-axis labels.

useHCColors

A logical value. If TRUE panelTitleColors

are not used, instead panel title are automatically chosen to have high contrast against colors.

legendAtSide

A logical value that forces panel title to be shown on the y-axis, instead of over the plot.

outfolder

Path to output folder to write plot images. Is NULL, plot are rendered on the default device

outfileType

File format of the output files used if outfolder is not NULL. Accepted values are 'png', 'jpeg', 'tiff', 'pdf'. Each value selects the graphic device of the same name. The name of the image file is the name of bin with the corresponding extension given by the chosen type

deviceOpt

A list of named options to be passed to the graphic device selected in outfileType

Value

Returns a png for each selected bin

Author(s)

Estefania Mancini, Andres Rabinovich, Javier Iserte, Marcelo Yanovsky, Ariel Chernomoretz

See Also

plotGenomicRegions,

Examples

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  # Create a transcript DB from gff/gtf annotation file.
  # Warnings in this examples can be ignored. 
  #library(GenomicFeatures)
  #genomeTxDb <- makeTxDbFromGFF( system.file('extdata','genes.mini.gtf', 
  #                               package="ASpli") )
  
  # Create an ASpliFeatures object from TxDb
  #features <- binGenome( genomeTxDb )
  
  # Define bam files, sample names and experimental factors for targets.
  #bamFileNames <- c( "A_C_0.bam", "A_C_1.bam", "A_C_2.bam", 
  #                   "A_D_0.bam", "A_D_1.bam", "A_D_2.bam",
  #                   "B_C_0.bam", "B_C_1.bam", "B_C_2.bam", 
  #                   "B_D_0.bam", "B_D_1.bam", "B_D_2.bam" )
                     
  #targets <- data.frame( 
  #             row.names = paste0('Sample_',c(1:12)),
  #             bam = system.file( 'extdata', bamFileNames, package="ASpli" ),
  #             factor1 = c( 'A','A','A','A','A','A','B','B','B','B','B','B'),
  #             factor2 = c( 'C','C','C','D','D','D','C','C','C','D','D','D') )
  
  # Load reads from bam files
  #bams <- loadBAM( targets )
  
  # Read counts from bam files
  #counts   <- readCounts( features, bams, targets, cores = 1, readLength = 100, 
  #                        maxISize = 50000 )
  
  # Calculate differential usage of genes, bins and junctions 
  #du       <- DUreport.norm( counts, targets , contrast = c(1,-1,-1,1))

  # Calculate PSI / PIR for bins and junction.
  #as       <- AsDiscover( counts, targets, features, bams, readLength = 100, 
  #                        threshold = 5, cores = 1 )
  
  # Plot bin data. Factor2 is the main factor for graphic representation in
  # this example as it is the first in factorsAndValues argument.
  # This makes a bar plot comparing four conditions, grouped by factor1.
  #plotBins( counts, as, 'GENE03:E002', 
  #  factorsAndValues = list( 
  #    factor2 = c('C','D'), 
  #    factor1 = c('A','B') ),
  #  las.x = 1,
  #  legendAtSide = TRUE,
  #  useHCColors = TRUE,   
  #  targets = targets,
  #  barWidth = 0.95,
  #  innerMargins = c( 2.1, 4.1, 1.1, 1.1 ) )
    
    
  # Redefine targets  
  #targets <- data.frame( 
  #             row.names = paste0('Sample_',c(1:12)),
  #             bam = system.file( 'extdata', bamFileNames, package="ASpli" ),
  #             factor1 = c( 'A','A','B','B','C','C','D','D','E','E','F','F') )
  
  #as       <- AsDiscover( counts, targets, features, bams, readLength = 100, 
  #                        threshold = 5, cores = 1 )
  
  # This makes a line plot for six conditions, grouped by factor1.                       
  #plotBins( counts, as, 'GENE03:E002', 
  #  factorsAndValues = list( 
  #    factor1 = c('A','B','C','D','E','F') ),
  #  las.x = 1,
  #  legendAtSide = FALSE,
  #  targets = targets,
  #  innerMargins = c( 2.1, 4.1, 1.1, 1.1 ) )                        
  

chernolab/ASpli documentation built on March 11, 2021, 12:24 a.m.