Entering edit mode
5.0 years ago
SSK
▴
10
Hi. I'm trying to do random sampling with R. When I run
library(GenomicAlignments)
library(rtracklayer)
## your bam file
bam.file <- 'your_bam_file.bam'
## is it paired end or not
paired <- TRUE
## read in the bam file
if(paired){
bam.input <- readGAlignmentPairs(bam.file)
}else{
bam.input <- readGAlignments(bam.file)
}
## select your number of subsets
num.samples <- 100
## subsample WITH replacement
bam.subsample <- sample(bam.input,num.samples,replace=TRUE)
## export new bam file
export(bam.subsample,BamFile('bam_subsampled.bam'))
I get the following error message
[E::hts_idx_push] Region 554468587..554468738 cannot be stored in a bai index. Try using a csi index with min_shift = 14, n_lvls >= 6
value[[3L]](cond) でエラー: 'asBam' failed to build index
file: bam_subsampled.bam
SAM file: 'bam_subsampled.sam'
追加情報: 警告メッセージ:
.make_GAlignmentPairs_from_GAlignments(gal, strandMode = strandMode, で:
79328 alignments with ambiguous pairing were dumped.
Use 'getDumpedAlignments()' to retrieve them from the dump environment.
I searched for csi option in Rsamtools or GenomicAlignmets, but I wasn't able to find that.
How can I solve this error ?? Thanks.
I got this code from C: Sampling random reads from BAM files with allowing same reads