Skip to content

Instantly share code, notes, and snippets.

Avatar

sirusb

  • St. Jude Children's Research Hospital
  • Memphis
View GitHub Profile
View CheckSingleOrPairEndSeq.r
require(RNAseqData.HNRNPC.bam.chr14)
require(pasillaBamSubset)
require(Rsamtools)
bamFile <- untreated1_chr4()
# نلاحظ أن المجموعة اس هي المتواجدة هنا مما يدل على ان السلاسل احادية النهاية
quickBamFlagSummary(bamFile, main.groups.only = TRUE)
# group | nb of | nb of | mean / max
# of | records | unique | records per
# records | in group | QNAMEs | unique QNAME
View ScanParam_exmaple.r
require(pasillaBamSubset)
require(Rsamtools)
bamFile <- untreated1_chr4()
region <- GRanges("chr4",IRanges(100000L, 110000L))
param <- ScanBamParam(which=region, what=scanBamWhat())
mappedReads <- scanBam(bamFile, param=param)
View GAlignments_example.r
require(pasillaBamSubset)
require(GenomicAlignments)
# BAM نقراء الملف
bamFile <- untreated1_chr4()
gReads <- readGAlignmentsFromBam(bamFile)
#GAlignments object with 204355 alignments and 0 metadata columns:
# seqnames strand cigar qwidth start end width njunc
# <Rle> <Rle> <character> <integer> <integer> <integer> <integer> <integer>
# [1] chr4 - 75M 75 892 966 75 0
# [2] chr4 - 75M 75 919 993 75 0
View Importing_bed.r
# rtracklayer يمكن استعمال الدوال الجاهزة في حزمة
encodePilotRegions <- import.bed("encodePilotRegion.bed")
encodePilotRegions
#GRanges object with 44 ranges and 1 metadata column:
# seqnames ranges strand | name
# <Rle> <IRanges> <Rle> | <character>
# [1] chr1 [151158061, 151658060] * | ENr231
# [2] chr2 [ 51658705, 52158704] * | ENr112
# [3] chr2 [118294574, 118794573] * | ENr121
# [4] chr2 [220277346, 220777345] * | ENr331
View access_GR.r
gr[1:2]
#GRanges object with 2 ranges and 1 metadata column:
# seqnames ranges strand | score
# <Rle> <IRanges> <Rle> | <numeric>
# [1] chr1 [ 130, 379] + | 0.0297835641540587
# [2] chr1 [30050, 31349] + | 0.42395940516144
# -------
# seqinfo: 3 sequences from an unspecified genome; no seqlengths
start(gr)
View GRanges_construction.r
# بعدة طرق GRanges يمكن انشاء
# مثلا يمكننا تحديد فقط المجالات الجينومية
gr <- GRanges(seqnames = c("chr1","chr1","chr2","chrX"),
ranges = IRanges(start = c(130,30050,4509,69098),
width= c(250,1300,400,590)),
strand = c("+","+","-","*"))
gr
#GRanges object with 4 ranges and 0 metadata columns:
# seqnames ranges strand
# <Rle> <IRanges> <Rle>
@sirusb
sirusb / Re_example.r
Last active Aug 29, 2015
Rle example
View Re_example.r
# ننشئ شعاع يحتوي على أرقام من 1 إلى 10 بطول 40
x<- sort(sample(1:10,40,replace=T))
head(x)
#[1] 1 1 1 1 1 1
# Rle لحفضه
x <- Rle(x)
x
#integer-Rle of length 40 with 10 runs
# Lengths: 6 2 1 3 4 5 6 9 2 2
# Values : 1 2 3 4 5 6 7 8 9 10
View IRanges_manipulations.r
range1 <- IRanges(start=c(10,50,300),end =c(60,90,456))
range1
#IRanges of length 3
# start end width
#[1] 10 60 51
#[2] 50 90 41
#[3] 300 456 157
reduce(range1)
#IRanges of length 2
@sirusb
sirusb / Ranges_Example.r
Last active Aug 29, 2015
IRanges example
View Ranges_Example.r
library(IRanges)
# يمكن انشاء مجموعة مجالات بتحديد نقطة البداية والنهاية
range1 <- IRanges(start=c(10,50,300),end =c(30,90,456))
range1
#IRanges of length 3
# start end width
#[1] 10 30 21
#[2] 50 90 41
#[3] 300 456 157
@sirusb
sirusb / GC_content.r
Last active Aug 29, 2015
Example counting GC content
View GC_content.r
# نقوم بتحميل مواقع جزر السي بي جي لكامل الجينوم
dataURL <-"http://bios221.stanford.edu/data/model-based-cpg-islands-hg19.txt"
cpglocs=read.table(dataURL ,header=T)
# نختار فقظ الكروموزم رقم 8
cpglocs8=cpglocs[which(cpglocs[,1]=="chr8"),2:3]
# الجدول يحتوي على أماكن بداية ونهاية كل جزيرة
head(cpglocs8)
# start end