Yes that was one of my first idea but I would like to avoid multiple files.
Hi,
I've some data that I want to load into IGV. It represents some viral integration sites for a bunch of samples. For each integration site I've :
- chromosome
- start
- end (in fact start+1)
- strand (tell us the orientation of the virus relative to the reference genome)
- sample id
What I want is to have a separate track for each sample id and to have different colors for + and - strand integration sites ? Is that possible ?
Thanks
1 answer
To have each sample on a separate track you need a file per sample. To visualize features depending on strand, you could make your tracks as bedGraph (format: chrom, start, end, score). In the score field put 1 if strand is positive, -1 otherwise. Then in IGV you can assign different colour to values positive or negative.
To split your samples in individual files you can first sort by position (sort -k1,1 -k2,2n samples.txt > sorted.txt) then put one sample per bedgraph file with score as above with something like:
prev=''
while read line
do
sample=`echo $line | cut -f 5 -d ' '` ## Get sample id
if [[ $sample != $prev ]]
then
bedgraph=${sample}.bedGraph ## Initialize new file name
fi
## Output bedGraph line
echo $line | awk -v OFS='\t' '{if($4 == "+"){strand= 1}else{strand= -1} print $1, $2, $3, strand}' >> $bedgraph
done < sorted.txt
(I assume you don't have hundreds of samples otherwise it would be messy)
Log in to answer this question.