This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to plot depth coverage plot?

Hello I want to plot whole chromosome depth coverage plot each chromosome size is 50Mb and they have 130Kb deletion. but when I made a plot using python It can't detect 130kb deletion (I did 10kb binning) what is my problem?

this is my python script

import sys
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('Agg')

input_file = sys.argv[1]

df = pd.read_table(input_file, sep = "\t", header = None)

y = [int(a) for a in df[2]]

n =10000
y_10000 = [y[i * n:(i + 1) * n] for i in range((len(y) + n - 1) // n )]

y_10000_mean = [sum(a)/len(a) for a in y_10000]

x = [b for b in range(len(y_10000_mean))]

plt.plot(x, y_10000_mean, '-', mfc='none' )
plt.ylim([0,13])
#plt.xlim([0,5346])
#plt.autoscale(enable = True)
plt.savefig(f'{input_file}_1kb.jpg', dpi = 500

Thanks

enter image description here

enter image description here

this is deletion

this is whole chromosome (10kb binning)

coverage binning python depth slidwindow

Please provide a sample of your input table and the plot you are getting. Otherwise it will be difficult to help you.

1 answer

The more standard way to do this would be to covert your BAM file into bigwig using, for example, deeptools bamcoverage, then view the results in a genome browser like IGV, Jbrowse2 desktop etc.

This allows you to see the annotation around the breakpoints as well, which is usually the follow up question.

Log in to answer this question.