This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bedGraph to bigwig

Hi everyone,

I am trying to visualize my bam.file (RNA-seq) using IGV. Following a combination of Biostar and a recommended step posted by #Matt Shirley,

  • I converted bam to bedgraph using bedtools genomecov -ibam
  • Generated the indexed sized genome using faidx input.fasta -i chromsizes
  • However, using the command line bedGraphToBigWig SAMPLE.bedgraph GENOME_FASTA_INDEX SAMPLE.STRANDRaw.bigwig, generated 0 byte-size bw file.
  1. My fasta.file is a small genome that contains 52 Contigs/scaffolds belonging to a one chromosome (Bacteria).
  2. Using the original fasta file also generated 0 byte-size bw file
  3. Is there any tool to merge the 52 contigs generated by Medusa scaffolder, and is such Merging essential for better downstream analysis' results?

Thank you

igv rna-seq

random note: you can easily generate a .chrom.sizes file with "samtools faidx", which generates a .fai file, and I believe you can even use the .fai in place of a .chrom.sizes since the first two columns of .fai are the chrom sizes

Actually, I started with the fai.file which generated the same 0byte bw file, and this is why I moved to the genomesize as recommended in several threads.

@ATpoint Yes, the resulting genomesize file showed a correct pattern (list of all contigs column1 and their sizes column2). However, although bam > bg was generated successfully, bg > bw resulted 0 byte file

My bad, I missed that you used the index file already. Please see my other suggestion.

Can you give a head of the bedGraph? I think bedtools needs the -bg flag to output bedGraph rather than its histogram-like default.

Here is the head of the bg.file (4 columns)

JAFJXZ01    5   2   934 0.00214133

JAFJXZ01    6   1   934 0.00107066

JAFJXZ01    9   2   934 0.00214133

JAFJXZ01    12  1   934 0.00107066

JAFJXZ01    13  2   934 0.00214133

JAFJXZ01    14  4   934 0.00428266

JAFJXZ01    16  2   934 0.00214133

JAFJXZ01    17  2   934 0.00214133

JAFJXZ01    18  3   934 0.00321199

JAFJXZ01    19  6   934 0.00642398

It is five columns, no? And indeed not bedGraph format. Try adding the -bg or -bga option to genomecov.

I included the argument -bg in my command line;

bedtools genomecov -ibam < input file name> -g <genome.gff> -bg <output name>

Although I got this error below, the command line resulted a bg file (yes, with 5 columns)

[mii] -g not found! Similar commands: "cc", "sq", "vs"

When I repeated same command with the genome.sizes file instead of gff, I got this error

Genome (-g) files are ignored when BAM input is provided.

Working on Linux

2 answers

Not sure if you problem is solved I think if you could try your approach on a hg38 or mm10 file and see if that work will be a good debug point It can validate if your problem is coming from your code or from the genome you are working on, or both (worst case)

Save yourself the trouble, and go directly from bam to bigwig with deeptools bamcoverage

https://deeptools.readthedocs.io/en/develop/content/tools/bamCoverage.html

Log in to answer this question.