Skip to content

Commit

Permalink
contig labels
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHarrop committed Oct 14, 2024
1 parent a1eb60b commit 3e95b33
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
40 changes: 37 additions & 3 deletions tools/plot_ragtag_paf/plot_ragtag_paf.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ names(all_colours) <- c(
# contigs later
message("Plotting")
gp <- ggplot() +
theme_void(base_family = "Lato", base_size = 12) +
theme_void(base_family = "Lato", base_size = fontsize) +
scale_fill_manual(
values = all_colours, guide = "none"
) +
Expand Down Expand Up @@ -248,15 +248,21 @@ gp <- ggplot() +
geom = "text",
label = "Query contigs",
x = middle_x,
y = q_y + (y_axis_space / 3),
y = ifelse(label_query_contigs == TRUE,
q_y + (y_axis_space * 2 / 3),
q_y + (y_axis_space / 3)
),
hjust = 0.5,
vjust = 0.5
) +
annotate(
geom = "text",
label = "Reference contigs",
x = middle_x,
y = t_y - (y_axis_space / 3),
y = ifelse(label_ref_contigs == TRUE,
t_y - (y_axis_space * 2 / 3),
t_y - (y_axis_space / 3)
),
hjust = 0.5,
vjust = 0.5
)
Expand All @@ -279,6 +285,34 @@ if (upside_down == TRUE) {
)
}

# reference contig names
if (label_ref_contigs == TRUE) {
gp <- gp + geom_text(
data = tpaf,
aes(
x = (shift_tstart + pad_tend) / 2,
y = t_y - (2.5 * polygon_y_bump),
label = tname
),
angle = 30,
hjust = ifelse(upside_down == TRUE, 0, 1)
)
}

# query contig names
if (label_query_contigs == TRUE) {
gp <- gp + geom_text(
data = qpaf,
aes(
x = (shift_qstart + pad_qend) / 2,
y = q_y + (2.5 * polygon_y_bump),
label = qname
),
angle = 30,
hjust = ifelse(upside_down == TRUE, 1, 0),
)
}

message("Writing the plot to file")
ggsave(plot_file,
gp,
Expand Down
13 changes: 0 additions & 13 deletions tools/plot_ragtag_paf/plot_ragtag_paf.Rproj

This file was deleted.

16 changes: 16 additions & 0 deletions tools/plot_ragtag_paf/plot_ragtag_paf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
palette_space: '${plot_params.palette_space}'
plot_height: '${plot_params.plot_height}'
plot_width: '${plot_params.plot_width}'
label_ref_contigs: '${plot_params.label_ref_contigs}'
label_query_contigs: '${plot_params.label_query_contigs}'
upside_down: '${upside_down}'
</configfile>
</configfiles>
Expand All @@ -54,6 +56,8 @@
<param type="integer" name="plot_width" label="Plot width (mm)" value="254"/>
<param type="integer" name="plot_height" label="Plot height (mm)" value="191"/>
<param type="integer" name="fontsize" label="Fontsize (pt)" value="12"/>
<param type="boolean" name="label_ref_contigs" label="Print the names of the reference contigs" value="false" truevalue="TRUE" falsevalue="FALSE"/>
<param type="boolean" name="label_query_contigs" label="Print the names of the query contigs" value="false" truevalue="TRUE" falsevalue="FALSE"/>
<param type="integer" name="palette_space" label="Number of unused colours in the colour palette between the query contig colour and the colour of the first reference contig." help="Try a higher value if the query contigs look too similar to the reference contigs." value="4"/>
<param type="float" min="0" max="1" name="gap_size" label="Total length of gaps between contigs relative to the total assembly length." help="Try a higher value if the contigs look too close together." value="0.1"/>
</section>
Expand Down Expand Up @@ -81,6 +85,18 @@
</assert_contents>
</output>
</test>
<test expect_num_outputs="1">
<param name="input_paf" ftype="paf.gz" value="ragtag.paf.gz"/>
<param name="input_agp" ftype="agp" value="ragtag.agp"/>
<param name="upside_down" value="true"/>
<param name="label_query_contigs" value="true"/>
<param name="label_ref_contigs" value="true"/>
<output name="plot">
<assert_contents>
<has_size size="11159" delta="1000"/>
</assert_contents>
</output>
</test>
</tests>
<help>
Accepts the PAF and AGP produced by the RagTag Scaffold and draws a plot
Expand Down

0 comments on commit 3e95b33

Please sign in to comment.