Contents

1 About APAlyzer

APAlyzer is a toolkit for bioinformatic analysis of alternative polyadenylation (APA) events using RNA sequencing data. Our main approach is comparison of sequencing reads in regions demarcated by high quality polyadenylation sites (PASs) annotated in the PolyA_DB database (http://exon.njms.rutgers.edu/polya_db/v3/) (Wang et al. 2017, 2018). The current version uses RNA-seq data to examine APA events in 3’ untranslated regions (3’UTRs) and in introns. The coding regions are used for gene expression calculation.

2 Program installation

APAlyzer should be installed using BiocManager:

if (!"BiocManager" %in% rownames(installed.packages()))
     install.packages("BiocManager")
BiocManager::install("APAlyzer")

Alternatively, it can also be installed as follows:

R CMD INSTALL APAlyzer.tar.gz

In additions, user can also install development version of APAlyzer directly from GitHub:

BiocManager::install('RJWANGbioinfo/APAlyzer')

After installation, APAlyzer can be used by:

library(APAlyzer)

3 Sample data and PAS references

3.1 RNA-seq BAM files

The package reads BAM file(s) to obtain read coverage information in different genomic regions. The following example shows that we first specify paths to example BAM files in the TBX20BamSubset (Bindreither 2018) data package. In this example, BAM files correspond to mouse RNA-seq data, (mapped to mm9).

suppressMessages(library("TBX20BamSubset"))
suppressMessages(library("Rsamtools"))
flsall = getBamFileList()
flsall
##                                                                      SRR316184 
## "/home/biocbuild/bbs-3.11-bioc/R/library/TBX20BamSubset/extdata/SRR316184.bam" 
##                                                                      SRR316185 
## "/home/biocbuild/bbs-3.11-bioc/R/library/TBX20BamSubset/extdata/SRR316185.bam" 
##                                                                      SRR316186 
## "/home/biocbuild/bbs-3.11-bioc/R/library/TBX20BamSubset/extdata/SRR316186.bam" 
##                                                                      SRR316187 
## "/home/biocbuild/bbs-3.11-bioc/R/library/TBX20BamSubset/extdata/SRR316187.bam" 
##                                                                      SRR316188 
## "/home/biocbuild/bbs-3.11-bioc/R/library/TBX20BamSubset/extdata/SRR316188.bam" 
##                                                                      SRR316189 
## "/home/biocbuild/bbs-3.11-bioc/R/library/TBX20BamSubset/extdata/SRR316189.bam"

3.2 Genomic reference

PAS references in the genome (both 3’UTRs and introns) are required by our package. We have pre-built a reference file for the mouse genome (mm9), which can be loaded from extdata:

library(repmis)
URL="https://github.com/RJWANGbioinfo/PAS_reference_RData/blob/master/"
file="mm9_REF.RData"
source_data(paste0(URL,file,"?raw=True"))
## Downloading data from: https://github.com/RJWANGbioinfo/PAS_reference_RData/blob/master/mm9_REF.RData?raw=True
## SHA-1 hash of the downloaded data file is:
## fa117a77976a6931e4755a3182544df1d1de7eb6
## [1] "refUTRraw" "dfIPA"     "dfLE"

This extdata covers 3’UTR APA regions (refUTRraw), IPA regions (dfIPA), and 3’-most exon regions (dfLE). The refUTRraw is a data frame containing 6 columns for genomic information of 3’UTR PASs:

head(refUTRraw,2)
##   gene_symbol Chrom Strand   First    Last  cdsend
## 1        Xkr4  chr1      - 3204561 3189814 3206103
## 2      Lypla1  chr1      + 4835237 4836816 4835097

dfIPA is a data frame containing 8 columns for Intronic PASs; ‘upstreamSS’ means the closest 5’ or 3’ splice site to IPA, ‘downstreamSS’ means closest 3’ splice site:

head(dfIPA,2)
##              PASid gene_symbol Chrom Strand      Pos upstreamSS downstreamSS
## 5  chr4:32818455:+        Mdn1  chr4      + 32818455   32818305     32818889
## 10 chr4:32837613:+        Mdn1  chr4      + 32837613   32837452     32837887

dfLE is a data frame containing 5 colmuns for 3’ least exon; ‘LEstart’ means the start genomic position of last 3’ exon.

head(dfLE,2)
##     gene_symbol Chrom Strand  LEstart      TES
## 1 0610009O20Rik chr18      + 38421534 38425118
## 2 0610010F05Rik chr11      - 23465136 23462079

In additions to mouse mm9, our package has also a pre-build version for mouse mm10, human hg38 and human hg19 genome:

URL="https://github.com/RJWANGbioinfo/PAS_reference_RData/blob/master/"
file="hg19_REF.RData"
source_data(paste0(URL,file,"?raw=True"))
## Downloading data from: https://github.com/RJWANGbioinfo/PAS_reference_RData/blob/master/hg19_REF.RData?raw=True
## SHA-1 hash of the downloaded data file is:
## 7ba8e91beba626318e48736692d6442480d1ef06
## [1] "refUTRraw_hg19" "dfIPA_hg19"     "dfLE_hg19"

More pre-build refercence can be found at the reference and testing data repo: https://github.com/RJWANGbioinfo/PAS_reference_RData_and_testing_data

3.3 Building 3’UTR and intronic PAS reference region at once

To quantify the relative expression of PAS, we will need to build the reference regions for them, although this can be build separately in previous version. We also provide a new fouction REF4PAS starting from APAlyzer 1.2.1 to build these regions at once:

refUTRraw=refUTRraw[which(refUTRraw$Chrom=='chr19'),]
dfIPAraw=dfIPA[which(dfIPA$Chrom=='chr19'),]
dfLEraw=dfLE[which(dfLE$Chrom=='chr19'),]   
PASREF=REF4PAS(refUTRraw,dfIPAraw,dfLEraw)
UTRdbraw=PASREF$UTRdbraw
dfIPA=PASREF$dfIPA
dfLE=PASREF$dfLE    

In this case, UTRdbraw is the reference region used for 3’UTR APA analysis, while dfIPA and dfLE are needed in the intronic APA analysis.

3.4 Building 3’UTR PAS and IPA reference using GTF files

Although we highly suggest user use references regions genrated from PolyA_DB. Start from APAlyzer 1.2.1, we also provide a new fouction that can help users to build their reference directly from gene annotation GTF files, we hope this can help the species which are not covered by the PolyA_DB yet:

## build Reference ranges for 3'UTR PASs in mouse
download.file(url='ftp://ftp.ensembl.org/pub/release-99/gtf/mus_musculus/Mus_musculus.GRCm38.99.gtf.gz',
          destfile='Mus_musculus.GRCm38.99.gtf.gz')           
GTFfile="Mus_musculus.GRCm38.99.gtf.gz" 
PASREFraw=PAS2GEF(GTFfile)  
refUTRraw=PASREFraw$refUTRraw
dfIPAraw=PASREFraw$dfIPA
dfLEraw=PASREFraw$dfLE
PASREF=REF4PAS(refUTRraw,dfIPAraw,dfLEraw)

4 Analysis of APA in 3’UTRs

4.1 Building aUTR and cUTR references

To calculate 3’UTR APA relative expression (RE), we first need to define the refence regions of aUTR and cUTR using refUTRraw. Since the sample data only contains mapping information on chr19, we can zoom into reference regions on chr19 only:

refUTRraw=refUTRraw[which(refUTRraw$Chrom=='chr19'),]
UTRdbraw=REF3UTR(refUTRraw)

The REF3UTR function returns a genomic range containing aUTR(pPAS to dPAS) and cUTR(cdsend to pPAS) regions for each gene:

head(UTRdbraw,2)
## GRangesList object of length 2:
## $`1700020D05Rik__aUTR`
## GRanges object with 1 range and 2 metadata columns:
##         seqnames          ranges strand |   gene_symbol           gene_name
##            <Rle>       <IRanges>  <Rle> |      <factor>         <character>
##   10082    chr19 5492231-5495277      - | 1700020D05Rik 1700020D05Rik__aUTR
##   -------
##   seqinfo: 21 sequences from an unspecified genome; no seqlengths
## 
## $`1700020D05Rik__cUTR`
## GRanges object with 1 range and 2 metadata columns:
##          seqnames          ranges strand |   gene_symbol           gene_name
##             <Rle>       <IRanges>  <Rle> |      <factor>         <character>
##   100821    chr19 5495277-5502867      - | 1700020D05Rik 1700020D05Rik__cUTR
##   -------
##   seqinfo: 21 sequences from an unspecified genome; no seqlengths

4.2 Calculation of relative expression

Once cUTR and aUTR regions are defined, the RE of 3’UTR APA of each gene can be calculated by PASEXP_3UTR:

DFUTRraw=PASEXP_3UTR(UTRdbraw, flsall, Strandtype="forward")
## [1] "SRR316184, Strand: forward, finished"
## [1] "SRR316185, Strand: forward, finished"
## [1] "SRR316186, Strand: forward, finished"
## [1] "SRR316187, Strand: forward, finished"
## [1] "SRR316188, Strand: forward, finished"
## [1] "SRR316189, Strand: forward, finished"

The PASEXP_3UTR 3UTR requires two inputs: 1) aUTR and cUTR reference regions, and 2) path of BAM file(s). In additions to input, one can also define the strand of the sequencing using Strandtype. The detailed usage can also be obtained by the command ?PASEXP_3UTR.The output data frame covers reads count (in aUTR or cUTR), RPKM (in aUTR or cUTR) and RE (log2(aUTR/cUTR)) for each gene:

head(DFUTRraw,2)
##     gene_symbol SRR316184_areads SRR316184_aRPKM SRR316184_creads
## 1 1700020D05Rik                0               0               55
## 2 1810009A15Rik                0               0                0
##   SRR316184_cRPKM SRR316184_3UTR_RE SRR316185_areads SRR316185_aRPKM
## 1        105.4447              -Inf                0               0
## 2          0.0000               NaN                0               0
##   SRR316185_creads SRR316185_cRPKM SRR316185_3UTR_RE SRR316186_areads
## 1               47        87.28104              -Inf                0
## 2                0         0.00000               NaN                0
##   SRR316186_aRPKM SRR316186_creads SRR316186_cRPKM SRR316186_3UTR_RE
## 1               0               47        91.72928              -Inf
## 2               0                0         0.00000               NaN
##   SRR316187_areads SRR316187_aRPKM SRR316187_creads SRR316187_cRPKM
## 1                0               0               85        116.5675
## 2                0               0                0          0.0000
##   SRR316187_3UTR_RE SRR316188_areads SRR316188_aRPKM SRR316188_creads
## 1              -Inf                0               0               64
## 2               NaN                0               0                0
##   SRR316188_cRPKM SRR316188_3UTR_RE SRR316189_areads SRR316189_aRPKM
## 1        78.20346              -Inf                0               0
## 2         0.00000               NaN                0               0
##   SRR316189_creads SRR316189_cRPKM SRR316189_3UTR_RE
## 1               33        46.85651              -Inf
## 2                0         0.00000               NaN

5 Analysis of APA in introns

5.1 Building intronic polyA references

Analysis of IPA requires two genomic regions: IPA regions and 3’-most exons. As mentioned above, these regions in mouse and human genomes have been pre-built in the package:

#mouse(mm9):
URL="https://github.com/RJWANGbioinfo/PAS_reference_RData/blob/master/"
file="mm9_REF.RData"
source_data(paste0(URL,file,"?raw=True"))
## Downloading data from: https://github.com/RJWANGbioinfo/PAS_reference_RData/blob/master/mm9_REF.RData?raw=True
## SHA-1 hash of the downloaded data file is:
## fa117a77976a6931e4755a3182544df1d1de7eb6
## [1] "refUTRraw" "dfIPA"     "dfLE"
#human(hg19):
URL="https://github.com/RJWANGbioinfo/PAS_reference_RData/blob/master/"
file="hg19_REF.RData"
source_data(paste0(URL,file,"?raw=True"))
## Downloading data from: https://github.com/RJWANGbioinfo/PAS_reference_RData/blob/master/hg19_REF.RData?raw=True
## SHA-1 hash of the downloaded data file is:
## 7ba8e91beba626318e48736692d6442480d1ef06
## [1] "refUTRraw_hg19" "dfIPA_hg19"     "dfLE_hg19"

5.2 Calculation of relative expression

Similar to 3’UTR APA, RE of IPAs can be calculated using PASEXP_IPA: PASEXP_IPA:

dfIPA=dfIPA[which(dfIPA$Chrom=='chr19'),]
dfLE=dfLE[which(dfLE$Chrom=='chr19'),]
IPA_OUTraw=PASEXP_IPA(dfIPA, dfLE, flsall, Strandtype="forward", nts=1)

Note that, as a specific feature for IPA, one can set more threads using ‘nts=’(the parameter passed to Rsubread::featureCounts, check ?Rsubread::featureCounts for details) to increase calculation speed. The detailed usage can be obtained by the command ?PASEXP_IPA.

The output data frame contains read count and read density IPA upstream (a), IPA downstream (b) and 3’-most exon region (c). The RE of IPA is calculated as log2((a - b)/c).

head(IPA_OUTraw,2)
##     gene_symbol                         IPAID            PASid
## 1 9130011E15Rik chr19:45894071:-9130011E15Rik chr19:45894071:-
## 2 9130011E15Rik chr19:45952090:-9130011E15Rik chr19:45952090:-
##   SRR316184_IPA_UPreads SRR316184_IPA_UPRPK SRR316184_IPA_DNreads
## 1                     1            1.445087                     0
## 2                   104           12.453598                    26
##   SRR316184_IPA_DNRPK SRR316184_LEreads SRR316184_LERPK SRR316184_IPA_RE
## 1           0.0000000                96        59.47955        -5.363166
## 2           0.8276828                96        59.47955        -2.355049
##   SRR316185_IPA_UPreads SRR316185_IPA_UPRPK SRR316185_IPA_DNreads
## 1                     0             0.00000                     1
## 2                   121            14.48928                    20
##   SRR316185_IPA_DNRPK SRR316185_LEreads SRR316185_LERPK SRR316185_IPA_RE
## 1           1.6611296                96        59.47955         0.000000
## 2           0.6366791                96        59.47955        -2.102237
##   SRR316186_IPA_UPreads SRR316186_IPA_UPRPK SRR316186_IPA_DNreads
## 1                     0             0.00000                     0
## 2                   108            12.93258                    13
##   SRR316186_IPA_DNRPK SRR316186_LEreads SRR316186_LERPK SRR316186_IPA_RE
## 1           0.0000000                69        42.75093         0.000000
## 2           0.4138414                69        42.75093        -1.771866
##   SRR316187_IPA_UPreads SRR316187_IPA_UPRPK SRR316187_IPA_DNreads
## 1                     0             0.00000                     0
## 2                   199            23.82948                    22
##   SRR316187_IPA_DNRPK SRR316187_LEreads SRR316187_LERPK SRR316187_IPA_RE
## 1            0.000000                40        24.78315       0.00000000
## 2            0.700347                40        24.78315      -0.09964814
##   SRR316188_IPA_UPreads SRR316188_IPA_UPRPK SRR316188_IPA_DNreads
## 1                     1            1.445087                     0
## 2                   207           24.787451                    15
##   SRR316188_IPA_DNRPK SRR316188_LEreads SRR316188_LERPK SRR316188_IPA_RE
## 1           0.0000000                55        34.07683       -4.5595631
## 2           0.4775093                55        34.07683       -0.4872446
##   SRR316189_IPA_UPreads SRR316189_IPA_UPRPK SRR316189_IPA_DNreads
## 1                     1            1.445087                     0
## 2                   226           27.062627                    15
##   SRR316189_IPA_DNRPK SRR316189_LEreads SRR316189_LERPK SRR316189_IPA_RE
## 1           0.0000000                46        28.50062       -4.3017653
## 2           0.4775093                46        28.50062       -0.1003744

6 Significance analysis of APA events

Once the read coverage information is obtained for each sample, one can compare APA regulation difference between two different groups. In this analysis, there are two types of experimental design: 1) without replicates; 2) with replicates. A sample table will be generated according to the design:

# Build the sample table with replicates
sampleTable1 = data.frame(samplename = c(names(flsall)),
                    condition = c(rep("NT",3),rep("KD",3)))
sampleTable1
##   samplename condition
## 1  SRR316184        NT
## 2  SRR316185        NT
## 3  SRR316186        NT
## 4  SRR316187        KD
## 5  SRR316188        KD
## 6  SRR316189        KD
# Build the sample table without replicates
sampleTable2 = data.frame(samplename = c("SRR316184","SRR316187"),
                    condition = c("NT","KD")) 
sampleTable2
##   samplename condition
## 1  SRR316184        NT
## 2  SRR316187        KD

6.1 Significantly regulated APA in 3’UTRs

To analyze 3’UTR APA between samples (KD and NT groups in the example) without replicates, sampleTable2 is used. The function used here is called APAdiff (detailed information can be obtained by the command ?APAdiff). It will fist to go through the sample table to determine whether it is a replicate design or non-replicate design. Then the APA compassion will be performed.

# Analysis 3'UTR APA between KD and NT group using non-repilicate design
test_3UTRsing=APAdiff(sampleTable2,DFUTRraw, 
                        conKET='NT',
                        trtKEY='KD',
                        PAS='3UTR',
                        CUTreads=0)

The APAdiff function requires two inputs: 1) A sample table defining groups/conditions of the samples, and 2) read coverage information of aUTRs and cUTRs, which can be obtained by PASEXP_3UTR from the previous step. The group name, i.e., treatment or control, can be defined b trtKEY= and conKET=; the PAS type analyzed should be defined by PAS=; and the read cutoff used for aUTR and cUTR is defined by CUTreads= with the default value being 0. In the non-replicate design, the APA pattern will be compared between two samples and output will be shown in a data frame:

head(test_3UTRsing,2)
##     gene_symbol        RED    pvalue     p_adj APAreg
## 3 1810055G02Rik -0.1195816 1.0000000 1.0000000     NC
## 4 2700081O15Rik  0.3862662 0.3292784 0.8007581     NC
table(test_3UTRsing$APAreg)
## 
##  DN  NC  UP 
##  31 246   8

The output contains 4 columns: ‘gene symbol’ describes gene information; ‘RED’ is relative expression difference between two groups; ‘pvalue’ is statistical significance based on the Fisher’s exact test; ‘p_adj’ is FDR adjusted pvalue and ‘APAreg’ is 3’UTR APA regulation pattern in the gene. We define 3 types in ‘APAreg’, ‘UP’ means aUTR abundance in the treatment group (‘KD’ in this case) is at least 5% higher than that in control (‘NT’ in this case), and ‘pvalue’<0.05; ‘DN’ means aUTR abundance is 5% lower in treatment than that in control and p-value<0.05; ‘NC’ are the remaining genes. With respect to 3’UTR size changes, ‘UP’ means 3’UTR shortening, and ‘DN’ 3’UTR lengthening.

For the replicate design, we use t-test for significance analysis. However, other tools based on negative binomial data distribution, such as
DEXSeq (Anders, Reyes, and W. 2012) might also be used.

# Analysis 3'UTR APA between KD and NT group using multi-repilicate design
test_3UTRmuti=APAdiff(sampleTable1,
                        DFUTRraw, 
                        conKET='NT',
                        trtKEY='KD',
                        PAS='3UTR',
                        CUTreads=0)
head(test_3UTRmuti,2)
##     gene_symbol        RED     pvalue     p_adj APAreg
## 3 1810055G02Rik -0.7631689 0.08590526 0.4961374     NC
## 4 2700081O15Rik  0.1872116 0.07691742 0.4961374     NC
table(test_3UTRmuti$APAreg)
## 
##  DN  NC  UP 
##  24 226   8

In the replicate design, ‘RED’ is difference of averaged relative expression between two groups; ‘pvalue’ is the p-value from t-test. In this case, ‘UP’ is defined as ‘RED’ >0 and ‘pvalue’ <0.05; while ‘DN’ is the opposite; and ‘NC’ is the remaining genes.

6.2 Significantly regulated APA in introns

IPA comparison is similar to 3’UTR APA using APAdiff, except that it (1) uses IPA expression as input, and (2) ‘PAS=’ needs to be defined as ‘IPA’, and (3) the analysis is performed on each IPA. Note that, the direction of IPA regulation is similar to that of 3’UTR APA. This means ‘UP’ is defined as up-regulation of IPA (RED > 0); ‘DN’ is the opposite; and ‘NC’ is the remaining genes.

Analysis of IPA between KD and NT groups without replicates is shown here:

test_IPAsing=APAdiff(sampleTable2,
                        IPA_OUTraw, 
                        conKET='NT',
                        trtKEY='KD',
                        PAS='IPA',
                        CUTreads=0) 
head(test_IPAsing,2)
##     gene_symbol            PASid      RED       pvalue        p_adj APAreg
## 2 9130011E15Rik chr19:45952090:- 2.255401 1.790010e-12 3.615821e-10     UP
## 5        Ablim1 chr19:57151655:- 0.626637 5.392007e-01 1.000000e+00     NC

Analysis of IPA between KD and NT groups using replicate data is shown here:

test_IPAmuti=APAdiff(sampleTable1,
                        IPA_OUTraw, 
                        conKET='NT',
                        trtKEY='KD',
                        PAS='IPA',
                        CUTreads=0)
head(test_IPAmuti,2)
##     gene_symbol            PASid         RED      pvalue     p_adj APAreg
## 2 9130011E15Rik chr19:45952090:-  1.84729507 0.001294432 0.2808917     UP
## 5        Ablim1 chr19:57151655:- -0.09466715 0.900027947 0.9480877     NC

7 Visualization of analysis results

Start from APAlyzer 1.2.1, we provides two new fouction called APAVolcano and APABox for users to plot their RED results using volcano plot and box plot. In the volcano plot, users can also label the top genes using top= or a set of specific gene using markergenes=, for example:

APAVolcano(test_3UTRsing, PAS='3UTR', Pcol = "pvalue", top=5, main='3UTR APA')

In the box plot, RED is ploted on ‘UP’, ‘DN’, and ‘NC’ genes:

APABox(test_3UTRsing, xlab = "APAreg", ylab = "RED", plot_title = NULL)

In addtion to volcano and box plots, APA comparison result can be also plotted using either boxplots or violin plots or CDF curves. For the previous 3’UTR APA and IPA comparison outputs, one needs to first build the plotting data frame:

test_3UTRmuti$APA="3'UTR"
test_IPAmuti$APA="IPA"
dfplot=rbind(test_3UTRmuti[,c('RED','APA')],test_IPAmuti[,c('RED','APA')])

To make violin plots and CDF curves using ggplot2:

library(ggplot2)
###violin
ggplot(dfplot, aes(x = APA, y = RED)) + 
    geom_violin(trim = FALSE) + 
    geom_boxplot(width = 0.2)+ theme_bw() + 
    geom_hline(yintercept=0, linetype="dashed", color = "red")

###CDF
ggplot(dfplot, aes( x = RED, color = APA)) + 
    stat_ecdf(geom = "step") +
    ylab("cumulative fraction")+ 
    geom_vline(xintercept=0, linetype="dashed", color = "gray")+ theme_bw() + 
    geom_hline(yintercept=0.5, linetype="dashed", color = "gray")

8 Gene expression analysis using coding regions

APA is frequently involved in gene expression regulation. To compare gene expression vs. APA in different samples, our package provides a simple function to assess the expression changes using RNA-seq reads mapped to coding sequences.

8.1 Building coding region references

suppressMessages(library("GenomicFeatures"))
suppressMessages(library("org.Mm.eg.db"))
extpath = system.file("extdata", "mm9.chr19.refGene.R.DB", package="APAlyzer")
txdb=loadDb(extpath, packageName='GenomicFeatures')
IDDB = org.Mm.eg.db
CDSdbraw=REFCDS(txdb,IDDB)
## 'select()' returned many:1 mapping between keys and columns

8.2 Calculation of expression

DFGENEraw=GENEXP_CDS(CDSdbraw, flsall, Strandtype="forward")
## [1] "SRR316184, Strand: forward, finished"
## [1] "SRR316185, Strand: forward, finished"
## [1] "SRR316186, Strand: forward, finished"
## [1] "SRR316187, Strand: forward, finished"
## [1] "SRR316188, Strand: forward, finished"
## [1] "SRR316189, Strand: forward, finished"

9 Complete Analysis Example: APA analysis in mouse testis versus heart

9.1 About this dataset

To provide a complete tutorial of APA analysis using our package, we have now prepared a testing dataset through down sampling of mouse RNA-Seq data in heart (GSM900193) and testis (GSM900199):

Sample ID SRRID Sample Name Down sampling reads
GSM900199 SRR453175 Heart_Rep1 5 Million
GSM900199 SRR453174 Heart_Rep2 5 Million
GSM900199 SRR453173 Heart_Rep3 5 Million
GSM900199 SRR453172 Heart_Rep4 5 Million
GSM900193 SRR453143 Testis_rep1 5 Million
GSM900193 SRR453142 Testis_rep2 5 Million
GSM900193 SRR453141 Testis_rep3 5 Million
GSM900193 SRR453140 Testis_rep4 5 Million

9.2 Download the bam files

download_testbam()
flsall <- dir(getwd(),".bam")
flsall<-paste0(getwd(),'/',flsall)
names(flsall)<-gsub('.bam','',dir(getwd(),".bam"))

9.3 Build the PAS reference regions

library(repmis)
URL="https://github.com/RJWANGbioinfo/PAS_reference_RData/blob/master/"
file="mm9_REF.RData"
source_data(paste0(URL,file,"?raw=True"))
PASREF=REF4PAS(refUTRraw,dfIPA,dfLE)
UTRdbraw=PASREF$UTRdbraw
dfIPA=PASREF$dfIPA
dfLE=PASREF$dfLE

9.4 Calculation of relative expression of 3’UTR APA and IPA

UTR_APA_OUT=PASEXP_3UTR(UTRdbraw, flsall, Strandtype="invert")
IPA_OUT=PASEXP_IPA(dfIPA, dfLE, flsall, Strandtype="invert", nts=1)

9.5 Significantly regulated APA in 3’UTRs

############# 3utr APA #################
sampleTable = data.frame(samplename = c('Heart_rep1',
                                        'Heart_rep2',
                                        'Heart_rep3',
                                        'Heart_rep4',
                                        'Testis_rep1',
                                        'Testis_rep2',
                                        'Testis_rep3',
                                        'Testis_rep4'),
                        condition = c(rep("Heart",4),
                                    rep("Testis",4)))
                        
test_3UTRAPA=APAdiff(sampleTable,UTR_APA_OUT, 
                        conKET='Heart',
                        trtKEY='Testis',
                        PAS='3UTR',
                        CUTreads=5)
table(test_3UTRAPA$APAreg)                      
## 
##  DN  NC  UP 
## 490 719  80
APAVolcano(test_3UTRAPA, PAS='3UTR', Pcol = "pvalue", plot_title='3UTR APA')