Skip to content

Instantly share code, notes, and snippets.

@USMortality
Last active December 25, 2025 15:48
Show Gist options
  • Select an option

  • Save USMortality/0d3f9b917a16d58733b96e4c74497a3f to your computer and use it in GitHub Desktop.

Select an option

Save USMortality/0d3f9b917a16d58733b96e4c74497a3f to your computer and use it in GitHub Desktop.
Virus Hypothesis Tree
# Virus Hypotheses Tree - English & German versions
# Generates: virus_tree_en.png, virus_tree_de.png
generate_tree <- function(lang = "en") {
# Language-specific labels
labels <- if (lang == "en") {
list(
title = "Virus Hypotheses",
yes = "Yes", no = "No",
new = "new", not_new = "not new",
zoonosis = "Zoonosis", lab = "Lab",
influenza = "Influenza", other = "other\nexisting",
endogenous = "endogenous signal\n(human protein/s)",
random = "(partial) random/\nbackground signal",
bioagent = "local deployment of\nbio/chem agent",
mainstream = "Mainstream",
ext_mainstream = "extended mainstream"
)
} else {
list(
title = "Virus-Hypothesen",
yes = "Ja", no = "Nein",
new = "neu", not_new = "nicht neu",
zoonosis = "Zoonose", lab = "Labor",
influenza = "Influenza", other = "andere\nexistier.",
endogenous = "endogenes Signal\n(menschl. Protein/e)",
random = "(teilw.) zufälliges/\nHintergrundsignal",
bioagent = "lokaler Einsatz von\nBio-/Chem.-Kampfstoff",
mainstream = "Mainstream",
ext_mainstream = "erw. Mainstream"
)
}
filename <- sprintf("virus_tree_%s.png", lang)
png(filename, width=2200, height=1100, res=240)
par(mar=c(0.2, 0.2, 1, 0.2))
plot(NULL, xlim=c(0, 14), ylim=c(2, 10), axes=FALSE, xlab="", ylab="")
title(labels$title, font.main=2, cex.main=1.4)
# Helper: draw box with optional label
draw_box <- function(x, y, txt, col, w=1.8, h=0.7, label=NULL) {
rect(x-w/2, y-h/2, x+w/2, y+h/2, col=col, border="gray30", lwd=2)
text(x, y, txt, cex=1.0, font=2)
if (!is.null(label)) {
text(x+w/2-0.15, y+h/2-0.12, label, cex=0.6, font=2, col="gray30")
}
}
# Helper: draw arrow
arrow_down <- function(x1, y1, x2, y2) {
arrows(x1, y1-0.35, x2, y2+0.35, length=0.1, lwd=2.5, col="gray40")
}
# Root
draw_box(6.5, 9, "Virus?", "#CCCCCC", w=2)
# Level 1: Yes / No
arrow_down(6.5, 9, 3.2, 7.5)
arrow_down(6.5, 9, 10, 7.5)
draw_box(3.2, 7.5, labels$yes, "#98FB98", w=1.5)
draw_box(10, 7.5, labels$no, "#FFB6C1", w=1.5)
# Level 2 under Yes: new / not new
arrow_down(3.2, 7.5, 1.5, 5.8)
arrow_down(3.2, 7.5, 5, 5.8)
draw_box(1.5, 5.8, labels$new, "#87CEEB", w=1.4)
draw_box(5, 5.8, labels$not_new, "#DDA0DD", w=1.6)
# Level 3 under new: Zoonosis (H1) / Lab (H2)
arrow_down(1.5, 5.8, 0.7, 4)
arrow_down(1.5, 5.8, 2.3, 4)
draw_box(0.7, 4, labels$zoonosis, "#FFD700", w=1.3, label="H1")
draw_box(2.3, 4, labels$lab, "#FFD700", w=1.1, label="H2")
# Level 3 under not new: Influenza (H3) / other existing (H4)
arrow_down(5, 5.8, 4.2, 4)
arrow_down(5, 5.8, 6, 4)
draw_box(4.2, 4, labels$influenza, "#C8A2C8", w=1.4, label="H3")
other_w <- if (lang == "en") 1.2 else 1.3
rect(5.4, 3.575, 5.4 + other_w, 4.425, col="#C8A2C8", border="gray30", lwd=2)
text(5.4 + other_w/2, 4, labels$other, cex=0.8, font=2)
text(5.4 + other_w - 0.15, 4.3, "H4", cex=0.6, font=2, col="gray30")
# BLUE DASHED BOX around new + Zoonosis + Lab (extended mainstream)
rect(0, 3.3, 3, 6.5, border="darkblue", lwd=2.5, lty=2)
text(1.5, 6.8, labels$ext_mainstream, cex=0.7, col="darkblue", font=3)
# RED BOX around Zoonosis (mainstream)
rect(0.02, 3.4, 1.38, 4.6, border="darkred", lwd=3)
text(0.7, 3, labels$mainstream, cex=0.7, col="darkred", font=2)
# Level 2 under No: endogenous (H5) / random (H6) / bioagent (H7)
arrow_down(10, 7.5, 8, 5.3)
arrow_down(10, 7.5, 10, 5.3)
arrow_down(10, 7.5, 12, 5.3)
rect(7, 4.5, 9, 6.1, col="#FFA07A", border="gray30", lwd=2)
text(8, 5.3, labels$endogenous, cex=0.7, font=2)
text(8.85, 5.95, "H5", cex=0.6, font=2, col="gray30")
rect(9.1, 4.5, 10.9, 6.1, col="#FFA07A", border="gray30", lwd=2)
text(10, 5.3, labels$random, cex=0.65, font=2)
text(10.75, 5.95, "H6", cex=0.6, font=2, col="gray30")
rect(11, 4.5, 13, 6.1, col="#FFA07A", border="gray30", lwd=2)
text(12, 5.3, labels$bioagent, cex=0.65, font=2)
text(12.85, 5.95, "H7", cex=0.6, font=2, col="gray30")
dev.off()
cat("Created:", filename, "\n")
}
# Generate both versions
generate_tree("en")
generate_tree("de")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment