Question: Correct GC bias using read counts and Loess regression method
gravatar for fatima.m.zare
2.4 years ago by
fatima.m.zare20 wrote:

I read this post ( C: Compute Binned Gc-Normalized Read Counts From Bam File ) and I am wondering how can I remove GC content bias with Loess regression?

ADD COMMENTlink modified 3 months ago by Leon90 • written 2.4 years ago by fatima.m.zare20

If you have an issue with GC-bias, why not use computeGCBias and correctGCBias from deepTools?

ADD REPLYlink written 2.4 years ago by Devon Ryan90k

Actually I want write my own code. I want to know about the method that use loess output and do correction for read counts. but Thanks for your answer. I will look at them maybe I can find their methods.

ADD REPLYlink written 2.4 years ago by fatima.m.zare20
gravatar for Leon
3 months ago by
Leon90 wrote:

Get 300kb bin window:

bedtools makewindows -g hg38.chrom.size -w 300000 > hg38_300.bed

hg38.chrom.size like this:

chr13 114364328
chr18 80373285
chr21 46709983

Get gc content

bedtools nuc -fi hs38DH.fa -bed hg38_300.bed | cut -f 1-3,5 > 300.gc.bed

Get depth in each bin:

bedtools coverage -a hg38_300.bed -b S1901020.aln.bam > S1901020.counts

combine gc content and depth:

paste <(grep -v '#' 300.gc.bed) <(cut -f4 S1901020.counts)|sed '1i chr\tstart\tend\tGC\tRC' > nipt


RC_DT<- read.table('nipt',sep='\t',head=TRUE) gcCount.loess <- loess(RC~GC,data=RC_DT,control = loess.control(surface = "direct"),degree=2) predictions1<- predict (gcCount.loess,RC_DT$GC)
resi <- RC_DT$RC-predictions1
RC_DT$RC <- resi
the corrected RC in RC_DT$RC, more help about loess can be got in help document in R.

ADD COMMENTlink modified 3 months ago • written 3 months ago by Leon90

for MacOS users, use gsed instead if sed, otherwise you will get an error sed: 1: "1i chr\tstart\tend\tGC\tRC": command i expects \ followed by tex

ADD REPLYlink written 5 weeks ago by Grinch60
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 939 users visited in the last hour