Skip to content

Commit 3b11724

Browse files
docs
1 parent c56517d commit 3b11724

3 files changed

Lines changed: 51 additions & 13 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggpedigree
22
Title: An R Package for plotting pedigrees
3-
Version: 0.2.0
3+
Version: 0.3.0
44
Authors@R: c(
55
person("S. Mason", "Garrison", , email= "garrissm@wfu.edu", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0002-4804-6003"))

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# ggpedigree 0.3.0
2+
* Enhance the narrative of the plotting vignette to provide a more comprehensive understanding of the package's capabilities.
3+
14
# ggpedigree 0.2.0
25
* Extended functionality to include new plotting features, like handling multiple instances of
36
the same individual in a pedigree.

vignettes/plots.Rmd

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ knitr::opts_chunk$set(
2020

2121
# Introduction
2222

23-
This vignette demonstrates pedigree visualisation with `ggPedigree()` from `ggpedigree`.
24-
Internally, `ggPedigree()` leverages helpers from both {BGmisc} (ped2fam(), recodeSex()) and {ggpedigree} (`calculateCoordinates()`, `calculateConnections()`), and returns a standard `ggplot2` object, so any familiar ggplot syntax can be added afterward.
23+
This vignette demonstrates pedigree visualization with `ggPedigree()` from `ggpedigree`. Pedigree plots are central to fields like human genetics, behavioral science, and genealogy, where understanding lineage and familial relationships informs diagnosis, analysis, and interpretation.
2524

26-
We illustrate usage with two bundled data sets:
25+
`ggPedigree()` builds on `ggplot2` and `kinship2`, leveraging modular helpers from both `{BGmisc}` and `{ggpedigree}` to streamline plot generation while retaining full aesthetic flexibility.
2726

28-
- `potter` – extended wizarding family
27+
Unlike base R pedigree tools, this package returns a `ggplot2` object, meaning users can customize their output using familiar `ggplot2` syntax, themes, scales, and layering. Throughout this vignette, we walk through basic usage, layout control, status overlays, aesthetic customization, and faceting for multifamily visualization.
2928

30-
- `hazard`historical royalty
29+
We use two bundled example datasets (from `BGmisc`) to illustrate the package's capabilities. The first dataset, `potter`, contains a fictional wizarding family tree, while the second dataset, `hazard`, includes a a multigenerational historical pedigree with affected/unaffected status.
3130

3231

3332
# Basic usage
3433

34+
We begin by loading the required libraries. These include the main plotting package `ggpedigree`, helper utilities from `BGmisc`, and supporting tools for aesthetic and data manipulation.
35+
3536
```{r libraries, message=FALSE, warning=FALSE}
3637
library(ggpedigree) # ggPedigree lives here
3738
library(BGmisc) # helper utilities & example data
@@ -40,6 +41,9 @@ library(viridis) # viridis for color palettes
4041
library(tidyverse) # for data wrangling
4142
```
4243

44+
45+
The simplest usage requires a data frame and column names for family and individual IDs. Here’s a basic pedigree plot using the `potter` data:
46+
4347
```{r}
4448
data("potter")
4549
ggPedigree(potter,
@@ -48,22 +52,24 @@ ggPedigree(potter,
4852
)
4953
```
5054

51-
`ggPedigree()` automatically:
55+
Behind the scenes, `ggPedigree()`:
5256

5357
1. reshapes the data by family (`ped2fam()`),
5458

55-
2. recodes sex (`recodeSex()`),
59+
2. recodes sex (e.g., 0/1/NA) into semantic labels via `recodeSex()`
60+
61+
3. extracts a layout grid with `calculateCoordinates()`
5662

57-
3. computes node layout (`calculateCoordinates()`), and
63+
4. builds connection segments for spouses, siblings, parents, and offspring with `calculateConnections()`
5864

59-
4. draws spouse, parent, sibling, and offspring links (`calculateConnections()`).
65+
The result is returned as a `ggplot2` object, which allows immediate post-processing with standard `ggplot` syntax.
6066

61-
The result is a `ggplot2` object, so you can add any ggplot syntax to it.
6267

6368

6469
# Customizing the plot
6570

66-
All aesthetics reside in a config list; anything you omit falls back to the default.
71+
Users can control aesthetics via the `config` list.
72+
Most appearance settings are managed through a `config` list. If any options are omitted, they fall back to predefined defaults. For example, we can turn off sex-based fill color and assign specific colors to connection segments:
6773

6874
```{r}
6975
ggPedigree(
@@ -81,7 +87,8 @@ ggPedigree(
8187
)
8288
```
8389

84-
Because the result is just a ggplot object, regular layering applies:
90+
As with any `ggplot2` object, further theming and labeling can be applied using layers or themes. For instance:
91+
8592

8693
```{r}
8794
ggPedigree(potter,
@@ -90,11 +97,39 @@ ggPedigree(potter,
9097
) +
9198
theme_bw(base_size = 12)
9299
```
100+
This can be particularly useful for matching house styles in academic publications or removing clutter for presentations.
93101

94102

95103

96104
# Additional customization
97105

106+
In many applied settings, pedigrees include binary phenotypes such as affected/unaffected status. To incorporate this, use the `status_col` argument to point to a column containing the relevant variable.
107+
108+
```{r}
109+
data("hazard")
110+
111+
p <- ggPedigree(
112+
hazard,
113+
famID = "famID",
114+
personID = "ID",
115+
status_col = "affected",
116+
config = list(
117+
code_male = 0,
118+
sex_color = TRUE,
119+
affected = TRUE,
120+
unaffected = FALSE,
121+
affected_shape = 4
122+
)
123+
)
124+
125+
p
126+
```
127+
128+
The function will automatically assign different shapes to affected individuals. If the `status_col` isn't already a factor, `ggPedigree()` will coerce it. You can explicitly set what values correspond to "affected" and "unaffected" via the `config` list.
129+
130+
If you turn off sex-based coloring, `ggPedigree()` will apply default `ggplot2` fill scales based on status:
131+
132+
98133
You can also add affected/unaffected status to the plot. The `status_col` argument allows you to specify a column in your data frame that contains the affected/unaffected status of each individual. This column should be a factor or character vector, and `ggPedigree()` will automatically recode it to a factor if necessary.
99134

100135
When you add the `status_col` argument, `ggPedigree()` will automatically color the affected individuals in one color and the unaffected individuals in another. You can indicate what the values of the affected/unaffected status are in your data frame using the `affected` and `unaffected` arguments in the `config` list. By default, `ggPedigree()` will overlay the affected individuals with a different shape, but you can customize this as well.

0 commit comments

Comments
 (0)