Hello,
I am plotting some features alongside 6 different chromosomes; each chromosome has a different length. The dataframe looks like this:
chromosome position count
String7 Int64 Int64
1 “Chrom_3” 10000 68
2 “Chrom_3” 20000 203
3 “Chrom_3” 30000 0
4 “Chrom_3” 40000 57
Now I am plotting like this
df|>
@vlplot(
:area,
width=800,height=70,
x={
:position,
axis={title=“Position”,grid=false},
scale={domain = (0, 20354777)}
},
y={
:count,
axis={title=“count”,grid=false}
},
color={
:chromosome,
legend=nothing
},
row={
:chromosome,
header={title=“Symbol”}
}
)
as you see, I gave to “scale” the length of the longest chromosome. However, this results in a somewhat annoying visual artefact, because the chromosomes vary greatly in size! one is almost half smaller than the longest one.
The problem with this visualization is that it can give the impression that many chromosomes have no feature at their ends, while it’s just there is nothing to see because we are outside of the chromosome.
I would love to have a different x-scale for each chromosome (I can’t show you the figure for confidentiality reasons).
Of course, I could explain in the plot legend that the axis represents the longest chromosome, but since one chromosome has a REAL feature of having gaps in its middle, it’s annoying that the others seem to have gaps at their end, because the viewer might confuse real gaps of features with gaps caused by the chromosome being of different sizes. (sorry I can’t share the pic, I hope my explanations make sense).
At the moment, each chromosome appears at the top of one another with the same general x-axis at the bottom, which goes from 0 to 20 millions.
So, is there a way to specify the scale for each row, by manipulating the “domain” keyword; or do I have to make 6 independent plots and then combine them one on top of the other?
Thanks a lot.
EDIT: another question, the documentation of the VegaLite package places brackets " around every word, but it seems it’s no more necessary? At least my code works without them.
EDIT2: how do I use the viridis color Palette?