Closed sapoudel closed 2 years ago
Hi @sapoudel, thanks for leaving a question, and apologize for the delayed response!
One thing that I am unsure of is what the value of newField parameter in gosling.DataTransform class is supposed to.
The newField
is a field name that will be generated by the data transform. It stores the row numbers (e.g., 1
, 2
, 3
, etc) after computing the pilling algorithm.
So, with the current code, these row numbers will be overwritten to the start
field.
I can find three parts that you can change to fix the issue:
newField
other than "start"
(e.g., newField="pileup"
)row
(i.e., add row=gos.Row("pileup:N")
)displacement=pile
. This is not needed since you already use pile
dataTransform
.This is an working example that you can refer to:
data = gos.bam(
url="https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam",
indexUrl="https://s3.amazonaws.com/gosling-lang.org/data/example_higlass.bam.bai",
)
base = gos.Track(data).transform_displace(
method="pile",
newField="pileup",
boundingBox=dict(
startField="start",
endField="end",
padding=5,
),
).transform_json_parse(
field="substitutions",
genomicField="pos",
baseGenomicField="start", // ← Change 1
genomicLengthField="length",
).properties(
height=500,
)
reads = base.mark_rect().encode(
x=gos.X("start:G"),
xe=gos.Xe("end:G"),
row=gos.Row("pileup:N", padding=0.2),
color=gos.value("#C8C8C8")
)
variants = reads.encode(
x=gos.X("pos_start:G"),
xe=gos.Xe("pos_end:G"),
color=gos.Color("variant:N"),
)
gos.overlay(reads, variants).properties(
xDomain=gos.GenomicDomain(chromosome="chr1", interval=[136750, 139450])
)
If you can share the full code, I can more accurately help you.
Thank you! I can fix my code using this example!
Hi, I am having trouble getting points to pile up. I tried something like this:
The above code passes validation but doesn't render anything if I pass
displacement
ordataTransform
toTrack
. I have tried using withdataTransform
parameter only, but no luck. One thing that I am unsure of is what the value ofnewField
parameter ingosling.DataTransform
class is supposed to.In case you need the full code, here it is: