MBG4181 Biyolojik Veri Analizi ve Görüntüleme - Ders1
2026-09-28
Surveys put ~80% of analysis time into getting the data ready: importing, tidying and transforming.
tidyverse makes you efficient in exactly that 80%.
| Tool | Shines at | But |
|---|---|---|
Linux terminal (grep, awk, sed) |
quick jobs on huge text files | no statistics or graphics, hard to reuse |
| Excel | small tables, quick charts, sharing | silent errors — turns gene symbols into dates (~1 in 5 papers!), not reproducible |
Python (pandas + Jupyter) |
general purpose scripting, machine learning | thinner tooling for genomics and statistics |
SQL (duckdb, databases) |
the lingua franca of data analysis: query databases and even CSV files directly (DuckDB), scales beyond memory | no statistics or graphics — pair it with R |
R (tidyverse + RStudio) |
statistics, visualization, Bioconductor with 2,000+ biology packages | base-R quirks — which we avoid with tidyverse |
All five can analyze data. We’ll see SQL again in this course; for biology we pick R: Bioconductor, reproducible scripts, free.
Per condition: how many genes, how many with expression above 350, and what fraction?
Reads like the question — no dialect, no hidden steps.
Same idea, but the two lambdas hide inside agg.
CASE WHEN boilerplate, twice.
All four give the same answer — the difference is what you can still read tomorrow.
On your own computer
Free, fast, works offline.
In the cloud
Posit Cloud — a full RStudio session in your browser, nothing to install. Free student plan.
Or use nothing at all: these slides run R themselves →
These slides carry their own R engine: webR — R compiled to WebAssembly, running in your browser. No installation, no cloud account.
quarto-webr extension — first run downloads the R engine, give it a few seconds
http://www.seec.uct.ac.za/r-tidyverse
gene, condition, exprR for Data Science https://r4ds.had.co.nz/
https://www.tychobra.com/posts/2020-05-27-new-dplyr-features/
https://rpubs.com/ekraichak/data-manipulation
| verb | action | example |
|---|---|---|
filter() |
Select rows based on some criteria | filter(age > 40 & treatment == "drug") |
arrange() |
Sort rows | arrange(date, group) |
select() |
Select columns (and ignore all others) | select(age, treatment) |
rename() |
Rename columns | rename(date = DATE_MONTHS_trial24) |
mutate() |
Add new columns | mutate(height.m = height.cm / 100) |
group_by(), summarise() |
Group data and then calculate summary statistics | group_by(treatment) |> summarise(...) |
select might look simple but it becomes very useful with helper functions
versus
https://datacarpentry.org/R-ecology-lesson/03-dplyr.html
https://www.gerkelab.com/blog/2018/09/import-directory-csv-purrr-readr/
There are lots of packages which follow the tidyverse principles which produce and work on tidy data.
This allows mixing packages/analysis from different domains
tidytext and tidygraph packages are great examples. Former allow text analysis by converting text data to tidy data (very long data frame, one word per row) and latter imports data frames to graphs and allows access to node or edge data with dplyr verbs.
janeaustenr::austen_books() |> #tidytext
unnest_tokens(bigram, text, token = "ngrams", n=2) |> #tidytext
filter(!is.na(bigram)) |> #dplyr
separate(bigram, into = c("word1","word2")) |> #tidyr
anti_join(stop_words, by=c("word1"="word")) |> #dplyr
anti_join(stop_words, by=c("word2"="word")) |> #dplyr
count(word1, word2, sort=T) |> #dplyr
filter(n>20) |> #dplyr
as_tbl_graph() |> #tidygraph
mutate(central=centrality_degree(mode = "all")) |> #dplyr/tidygraph
ggraph(layout = 'nicely') + #ggraph
geom_edge_link() +
geom_node_point(aes(color=central)) +
geom_node_label(aes(label=name), repel=T) +
theme_graph()The popular ggplot2 package is part of tidyverse.
For stunning figures in your publications, reports you’re encouraged to use ggplot2 package
Bioconductor paketleri listesinde “tidy” kelimesini aratınız.