ConvertToPE_BAM: Convert two BAM files into one paired-end BAM file.

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/ConvertToPE_BAM.R

Description

Stage 2 in MACPETUlt needs a paired-end BAM file to run. This can be created in Stage 1 using the usable_1 and usable_2 fastq files created in Stage 0. However the user might have two single-end BAM files already created but not paired (by filtering with another way than that in Stage 0 or mapping using another algorithm than that in Stage 1) and only needs to run Stages 2 and 3 in MACPETUlt. ConvertToPE_BAM can be used on the two BAM files for pairing them, and the resulted paired-end BAM file can then be used in Stage 2 in MACPETUlt.

Usage

1
2
3
ConvertToPE_BAM(S1_AnalysisDir = "", SA_prefix = "MACPET",
  S1_BAMStream = 2e+06, S1_image = TRUE, S1_genome = "hg19",
  BAM_file_1 = "", BAM_file_2 = "", S1_makeSam = FALSE)

Arguments

S1_AnalysisDir

The directory where the resulted paired-end BAM file will be saved.

SA_prefix

see MACPETUlt.

S1_BAMStream

see MACPETUlt.

S1_image

see MACPETUlt.

S1_genome

see MACPETUlt.

BAM_file_1

The directory of the BAM file with the first reads. Their Qnames have to end with /1.

BAM_file_2

The directory of the BAM file with the second reads. Their Qnames have to end with /2.

S1_makeSam

see MACPETUlt.

Details

The BAM files BAM_file_1 and BAM_file_2 do not need to be sorted, but their Qnames have to end with /1 and /2 respectively. Furthermore, the BAM files have to include the header section.

Value

A paired-end BAM file named SA_prefix_MACPET_Paired_end.bam and its index, saved in S1_AnalysisDir.

Author(s)

Ioannis Vardaxis, ioannis.vardaxis@ntnu.no

References

Vardaxis I, Drabløs F, Rye M and Lindqvist BH (2018). MACPET: Model-based Analysis for ChIA-PET. To be published.

See Also

MACPETUlt, SampleChIAPETDataRead_1.bam, SampleChIAPETDataRead_2.bam

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
requireNamespace('ggplot2')

#Create a temporary forder, or anywhere you want:
S1_AnalysisDir=file.path(tempdir(),'MACPETtest')
dir.create(S1_AnalysisDir)#where you will save the results

#directories of the BAM files:
BAM_file_1=system.file('extdata', 'SampleChIAPETDataRead_1.bam', package = 'MACPET')
BAM_file_2=system.file('extdata', 'SampleChIAPETDataRead_2.bam', package = 'MACPET')
SA_prefix='MACPET'

#convert to paired-end BAM:
ConvertToPE_BAM(S1_AnalysisDir=S1_AnalysisDir,
                SA_prefix=SA_prefix,
                S1_BAMStream=2000000,
                S1_image=TRUE,
                S1_genome='hg19',
                BAM_file_1=BAM_file_1,
                BAM_file_2=BAM_file_2)

#test if the resulted BAM is paired-end:
PairedBAM=file.path(S1_AnalysisDir,paste(SA_prefix,'_Paired_end.bam',sep=''))
Rsamtools::testPairedEndBam(file = PairedBAM, index = PairedBAM)

bamfile = Rsamtools::BamFile(file = PairedBAM,asMates = TRUE)
GenomicAlignments::readGAlignmentPairs(file = bamfile,use.names = FALSE,
                                       with.which_label = FALSE,
                                       strandMode = 1)

#-----delete test directory:
unlink(S1_AnalysisDir,recursive=TRUE)

IoannisVardaxis/MACPET documentation built on Aug. 9, 2019, 12:11 p.m.