BIOSCI 220 Notes (Week 01–02): R, Tidyverse, and Indigenous Data Sovereignty
R and RStudio basics
- What is R vs what is RStudio
- R: the computing language for statistics and data analysis.
- RStudio: a user-friendly integrated development environment (IDE) that helps you write, run, and organize R code.
- Learning focus: how to use R and how RStudio facilitates workflow (console, script editor, plots, etc.).
- Why use R? (Slide content overview)
- Free and open source.
- Huge online support network.
- Flexible; if you can code it, you can do it.
- Large community and ecosystem of packages.
- Relevance to research data analysis and reproducible workflows.
- Why use RStudio? (Slide content overview)
- Works nicely with R; integrates multiple tools in one interface.
- Large online support network and extensibility.
- Distinctive features: project management, built-in plots, help panes, etc.
- Key terminology (from the transcript):
- Functions: R commands that tell your computer what to do.
- Arguments: inputs you provide to functions that influence outputs.
- Packages: collections of functions; extend R’s capabilities.
- Running code: issuing commands in the console or running a script.
- Objects: values stored in R (variables, data frames, etc.).
- Script: a text file containing a set of commands and comments.
- Comments: notes within a script to document what’s happening.
- Example R code snippets mentioned in the slides (illustrative):
- Installing packages and loading libraries:
- install.packages(c(d¨plyr,¨r¨emotes)¨)
- library(dplyr)
- Using GitHub installations (as shown):
- remotes::installgithub(d¨jnavarro/jasmines)¨
- Simple art-style code snippet (illustrative):
- start<em>seed(123)%%entity</em>heart(grain=400)%%unfold<em>tempest(iterations=10)%%style</em>ribbon(background=w¨heat)¨
- Note: visuals and art-focused R packages are shown as examples of R’s flexibility.
R data types
- Integer (int): whole numbers; examples include 1,0,220; class is labeled as "integer" or int in R.
- Numeric (num / dbl): numbers with decimals or fractions; examples include −56.94,1.3; class is "numeric" or dbl in R.
- Logical (lgl): TRUE or FALSE; class is "logical".
- Character (chr): text strings; examples include "Charlotte" and "BIOSCI220"; class is "character".
- Quick summary (from slide content):
- Integers: extclass=extinteger(int).
- Numeric: extclass=extnumeric(num,dbl).
- Logical: extclass=extlogical(lgl).
- Character: extclass=extcharacter(chr).
Tidy data and data structure fundamentals
- Tidy data (Hadley Wickham): a standard for mapping dataset meaning to structure.
- Quote: "Tidy datasets are easy to manipulate, model and visualize …" ( Hadley Wickham, Tidy Data, JSS 2014 ).
- Core tidy data rules:
1) Each variable forms a column.
2) Each observation forms a row.
3) Each value is a single cell. - Why tidy data matters:
- Facilitates data manipulation, modeling, and visualization with a small, consistent toolbox.
- Practical takeaway:
- In tidy data, you can reliably apply the same functions across many datasets without special handling for messy shapes.
Piping and data wrangling with tidyverse
- Piping operator: %>%
- Concept: chaining operations in a readable left-to-right sequence.
- Example pattern: data %>% op1() %>% op2() %>% op3()
- A concrete example from slides:
- paua%%group<em>by(Species)%%summarise(av</em>length=mean(Length))
- Common errors (typical beginner mistakes):
- Typing library(tidy) instead of the package name; error: "there is no package called 'tidy'".
- Typing lbrary(tidyverse) (typo) resulting in: "could not find function 'lbrary'".
- Attempting to use a function that doesn’t exist yet, e.g., readcsv without loading the readr package or the tidyverse.
- Example data wrangling workflow with Palmer Penguins (tidyverse):
- Start by loading libraries:
- library(palmerpenguins)
- library(tidyverse)
- Remove missing values:
- penguins o{}nafree
<- penguins \%\% drop_na() - Basic grouped summaries:
- penguinsonafree%%group<em>by(species)%%summarise(av</em>length=mean(bill<em>length</em>mm))
- Example of a more complex pipeline:
- penguinsonafree%%filter(sex!=m¨ale)¨%%select(c(s¨pecies,¨i¨sland,¨b¨ody<em>mass</em>g)¨)%%group<em>by(species,island)%%summarise(total</em>mass<em>g=sum(body</em>mass<em>g))%%pivot</em>wider(names<em>from=c(island),values</em>from=total<em>mass</em>g)
- Summary from data wrangling recap (Page 27):
- A concise, reproducible pipeline using library(palmerpenguins) and library(tidyverse).
- Demonstrates filtering, selecting, grouping, summarising, and reshaping with pivot_wider.
Working with Palmer Penguins data (exploratory data analysis)
- Demonstration outputs shown in slides included:
- Example: penguinsnafree %>% groupby(species) %>% summarise(avgeragebilllength = mean(billlengthmm))
- Result (illustrative):
- species: Adelie, Chinstrap, Gentoo
- avgeragebilllength: 38.8,48.8,47.6 (units: mm)
- Example of a grouped summary table:
- Output shows per-species averages, e.g.,
- extspecies=Adelie→38.8
- extChinstrap=48.8,extGentoo=47.6
Data wrangling with real datasets and expressions
- Example: filtering, selecting, grouping, and summarising to compute total body mass by species and island, then pivotting to wide format for comparison:
- Pipeline (cleaned version):
- penguinsonafree%%filter(.,sex!=m¨ale)¨%%select(c(s¨pecies,¨i¨sland,¨b¨ody<em>mass</em>g)¨)%%group<em>by(species,island)%%summarise(total</em>mass<em>g=sum(body</em>mass<em>g))%%pivot</em>wider(names<em>from=c(island),values</em>from=total<em>mass</em>g)
- Interpretation:
- The resulting table shows, for each species, the total body mass across different islands.
ggplot2 basics and data visualization concepts
- ggplot2 overview: a package in the tidyverse for creating statistical graphics.
- Three key components of every ggplot:
1) Data: the data object (e.g., penguinsnafree).
2) Aesthetic mappings: how variables map to visual properties (e.g., x, y, color).
3) Layers: render observations with geoms (e.g., geompoint, geom_bar). - A minimal example (clean, correct form):
- library(palmerpenguins)
- library(tidyverse)
- penguinsonafree%%ggplot(data=penguinsonafree,aes(x=bill<em>length</em>mm,y=bill<em>depth</em>mm,color=species))+geompoint(size=2)
- Customizing colors and axes:
- Example: +scale<em>color</em>manual(values=c(d¨arkorange,¨d¨arkorchid,¨c¨yan4)¨)
- Example axis labels: +xlab(B¨illlength(mm))¨+ylab(B¨illdepth(mm))¨
- Common ggplot2 plots shown:
- Scatter plots: billlengthmm vs billdepthmm by species.
- Bar plots with facetting by island: ggplot(…)+geom<em>bar(…)+facet</em>wrap( island)
- Practice reminder: a plot typically requires data, aesthetics, and at least one geom layer.
- Ethics and impact of visualization (key notes):
- Visualizations are not neutral; they influence interpretation and decision-making.
- Quotes from practice slides emphasize responsibility in how data patterns and conclusions are presented (e.g., Correll, Rougier et al.).
- Ethical data practices in visualization require clarity, honesty, and awareness of audience and biases.
Data visualization ethics and interpretation
- Direct quotes and implications:
- "We have obligations in that we have a great deal of power over how people ultimately make use of data, both in the patterns they see and the conclusions they draw." (Michael Correll)
- General guidance: choose plots and scales that accurately reflect the data without overstating findings.
- Key takeaway: Data visualization is a powerful tool; responsible use is essential for credible science.
- What is Indigenous Data Sovereignty (IDSov)?
- Indigenous Data (ID): digital information derived from Indigenous people, their language, culture, and resources.
- IDSov: the inherent rights and interests Indigenous peoples have over the collection, ownership, and application of their data.
- Foundational reference: Kukutai & Taylor (2016) and Māori data sovereignty resources.
- International and national rights landscape:
- UN Declaration on the Rights of Indigenous Peoples (UNDRIP), 2007 (UN General Assembly resolution A/RES/61/295).
- Convention on Biological Diversity (CBD), 1992.
- Nagoya Protocol (2010): fair and equitable access and sharing of benefits arising from genetic resources.
- New Zealand’s Te Tiriti o Waitangi (Treaty) and alignment with UNDRIP principles.
- UNDRIP key themes (UNDRIP has 46 articles):
- Self-determination, equality and non-discrimination, participation, culture, land and resources.
- Article 31 explicitly discusses Indigenous rights to maintain, control, protect, and develop cultural heritage, traditional knowledge, and traditional cultural expressions (including genetic resources and knowledge).
- Te Tiriti o Waitangi (NZ Treaty) alignment with human rights:
- Article 1: right to self-determination for incoming settlers; democratic and citizenship rights.
- Article 2: right to self-determination for Tangata Whenua; indigenous rights and property rights.
- Article 3: equality and non-discrimination.
- Article 4: freedom of religion and beliefs.
- These articles align with international human rights documents like UNDRIP.
- CARE Principles of Indigenous Data Governance (wilkinson et al.; GIDA): four interrelated principles for data governance:
- Collective Benefit (C): data ecosystems should enable Indigenous peoples to derive benefits.
- C1. Inclusive development and innovation.
- C2. Improved governance and citizen engagement.
- C3. Equitable outcomes; benefits should accrue to Indigenous communities through responsible use and benefit-sharing.
- Authority to Control (A): Indigenous peoples’ rights to control data must be recognized and respected.
- A1. Recognizing rights and interests; informed consent and governance of collection.
- A2. Data for governance; data must be accessible to empower self-determination.
- A3. Governance of data; Indigenous communities should lead stewardship and access decisions.
- Responsibility (R): responsible data use, sharing outcomes, and governance.
- R1. Positive relationships; data use builds on trust and respect.
- R2. Expanding capability and capacity; developing Indigenous data workforce and infrastructure.
- R3. Indigenous languages and worldviews; data grounded in languages and lived experiences.
- Ethics (E): minimizing harm, ensuring justice, and considering future use.
- E1. Minimizing harm and maximizing benefit within Indigenous ethical frameworks and UNDRIP rights.
- E2. Justice; address power/resource imbalances.
- E3. Future use; consider potential future harms and benefits.
- Ngā Tikanga Paihere (Tikanga framework) – the 5 Safes framework with ethical data use practices:
- Principle 1: Have appropriate expertise, skills, and relationships with communities.
- Pūkenga (skills) and Whakapapa (community relationships).
- Principle 2: Maintain public confidence and trust; Pono (accountability) and Tika (transparency and value).
- Principle 3: Use good data standards and practices; Wānanga (organisational practices) and Kaitiaki (data stewardship).
- Principle 4: Have clear purpose and action; Wairua (community good) and Mauri (data provenance).
- Principle 5: Balance benefits and risks; Tapu (sensitivity) and Noa (benefit and opportunity).
- Core ethical takeaway from IDSov slides:
- Maori data sovereignty is about collective rights and interests; Māori data governance refers to mechanisms that give effect to those rights.
- The phrase “Not about us, without us” emphasizes inclusive decision-making and co-creation.
Indigenous data sovereignty in practice: case studies (New Zealand)
- Aotearoa Variome Project (Otago):
- Goal: co-develop a catalog of genetic variants for New Zealanders to understand population variation.
- Governance: Māori-led with co-development of consenting processes and ensuring benefits align with Te Ao Māori and kaitiakitanga.
- Outcome: a Māori-led genomic catalogue with governance designed to reflect Indigenous values.
- Rakeiora Project (Auckland):
- A pilot precision medicine infrastructure platform.
- Stand-alone scalable computational platform with co-design, governance, data sovereignty, and co-innovation incorporating mātauranga whakapapa.
- Emphasis on co-development between Māori and non-Māori leaders to ensure equitable access and governance.
- Summary of practical implications:
- National (Te Tiriti o Waitangi) and international (UNDRIP) instruments support Indigenous rights over genetic/genomic data.
- Ethical frameworks and governance structures (CARE, Ngā Tikanga Paihere) guide responsible data use and equitable benefit sharing.
- The goal is to expand genomic technologies and ethical data practices without exacerbating health disparities.
Diversity in genomics research and the GWAS data landscape
- Problem statement: Historically, genomic studies have underrepresented Indigenous and non-European populations.
- Key statistics (illustrative, pulled from slides):
- Total GWAS studies: 373; samples: 1.7extmillion in one period, 2,511 studies with 35extmillion samples, and 3,639 studies with 40extmillion samples (illustrative tabular data).
- Ancestry composition over time (examples):
- European Ancestry vs Non-European Ancestry in early waves: 88 ext{%} vs 12 ext{%} (2005–2018).
- 2005–2009: 96 ext{%} European vs 4 ext{%} non-European.
- 2005–2016: 80 ext{%} European vs 20 ext{%} non-European.
- Indigenous ancestry contribution to GWAS samples: < 1 ext{%} (very small share; often reported as micro-percentage values like 0.06 ext{%}, 0.05 ext{%}, 0.02 ext{%} in various periods).
- Diversity monitor (global context): interactive dashboards showing ancestry by participants over time, with parent terms like European, Asian, African, and Indigenous ancestry. These dashboards illustrate the persistent lack of representation for Indigenous and non-European groups in GWAS.
- Implications:
- Limited diversity in GWAS reduces the generalizability of genetic findings to all populations.
- There is a need for deliberate efforts to diversify genomic databases to improve health equity.
Global initiatives to diversify genomic data and ethical considerations
- Global initiatives aim to broaden representation and governance in genomic data:
- Silent Genomes Project: aims to diversify genomes and improve accessibility and governance.
- A draft human pangenome reference (Nature 2023): broadening the reference to represent global diversity beyond a single reference genome.
- Guiding question: Who benefits from this research and how should next-generation genomics tools be used to avoid widening health disparities?
- Practical takeaways:
- Building inclusive genetic resources requires collaboration with Indigenous communities and alignment with IDSov principles.
- Policies and infrastructures should support equitable access, governance, and benefit-sharing.
- Quote (contextual): Dr. Eric Green (NHGRI): to realize the promise of genomic medicine, organizations must commit to equitable expansion of responsible genomic data use.
Summary of IDSov frameworks and practical implications
- IDSov core definitions:
- Indigenous Data (ID): digital information derived from Indigenous groups.
- Indigenous Data Sovereignty (IDSov): inherent rights/claims over collection, ownership, and use of Indigenous data.
- Core principles and frameworks:
- CARE Principles: Collective Benefit, Authority to Control, Responsibility, Ethics.
- Ngā Tikanga Paihere: a Tikanga-based framework emphasizing the 5 Safes and related ethical practices.
- The CARE and Tikanga frameworks together provide a culturally grounded approach to data governance that foregrounds Indigenous rights, participation, and benefits.
- Key outcomes:
- Data sovereignty supports self-determination and governance over data that concern Indigenous communities.
- Research should be designed to maximize collective benefits and minimize harms, with transparent governance and reporting.
- Takeaway phrase: “Not about us, without us” signals the necessity of Indigenous involvement in all stages of data collection, analysis, and dissemination.
Case studies and practical implications recap
- Aotearoa Variome Project:
- Maori-led governance with co-design of processes to ensure consent is culturally appropriate and benefits align with Te Ao Māori and kaitiakitanga.
- Produces a catalog of genetic variants representative of New Zealanders while upholding data sovereignty.
- Rakeiora Project:
- Pathfinding genomic medicine infrastructure in Aotearoa/New Zealand.
- Stand-alone platform with co-design and governance; incorporates mātauranga whakapapa; co-innovation among Māori and non-Māori leadership.
- Overall implication:
- National and international agreements support Indigenous rights in genetic data.
- Ethical frameworks promote equitable benefits and prevent health disparities from widening as genomic medicine expands.
Conceptual connections and practical implications for exam readiness
- Core ideas to connect across modules:
- R basics and tidyverse underpin modern data science workflows used in ecology and genomics.
- Tidy data and the pipe operator enable clean, reproducible data manipulation pipelines.
- ggplot2 provides a consistent approach to data visualization; ethical visualization emphasizes accurate and responsible representation of data.
- Indigenous Data Sovereignty introduces critical, ethics-centered considerations for research involving Indigenous data, highlighting power dynamics, governance, and the need for community-led data stewardship.
- Practical exam-ready takeaways:
- Be able to explain the three core components of a ggplot2 plot and to assemble a basic scatter plot with proper aesthetics.
- Describe the tidy data principles and give examples of how a messy dataset would be transformed into tidy form using a pipe chain.
- Define IDSov and CARE principles, and explain how they would guide a hypothetical genomics study involving Indigenous populations.
- Summarize the international agreements (UNDRIP, CBD, Nagoya) and Te Tiriti o Waitangi, and discuss how they intersect with data governance and genomic research in a real-world setting.
- Notable formulas or equations in these slides:
- There are few explicit mathematical formulas in the deck; the emphasis is on data manipulation, summaries, and visualizations. When summarising data, common expressions include:
- avext−length=mean(billlengthmm)
- totalmassg=∑(bodymassg)
- In ggplot2 contexts, expressions are typically of the form: ggplot(data,aes(x,y,colour))+geompoint()
- Final reflection:
- The course emphasizes both technical data skills (R, tidyverse, ggplot2) and ethical, sociocultural considerations (IDSov, CARE, Tikanga) that shape how data-driven insights are produced and shared.
Quick glossary (key terms from the slides)
- R: The programming language used for statistics and data analysis.
- RStudio: Integrated development environment for R.
- tidy data: A dataset where each variable is a column, each observation is a row, and each value is a single cell.
- pipe (%>%): Operator enabling readable chains of data transformations.
- ggplot2: Grammar of graphics package for building layered plots.
- Palmer Penguins: A dataset frequently used in tutorials; example data for teaching data wrangling and visualization in R.
- Indigenous Data Sovereignty (IDSov): Inherent rights and interests of Indigenous peoples in relation to their data.
- CARE Principles: Collective Benefit, Authority to Control, Responsibility, Ethics (data governance framework).
- Ngā Tikanga Paihere: Tikanga-based ethical framework with the 5 Safes for responsible data use.
- UNDRIP: United Nations Declaration on the Rights of Indigenous Peoples (2007).
- CBD and Nagoya Protocol: Frameworks related to access, benefit-sharing, and biodiversity.
- Te Tiriti o Waitangi: The Treaty principles guiding Indigenous (Māori) rights in Aotearoa/New Zealand.
- Aotearoa Variome Project: Maori-led catalog of genetic variants for New Zealand.
- Rakeiora Project: Genomic medicine platform in NZ with co-design and data sovereignty.