## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(echo = TRUE)

## ----message=FALSE------------------------------------------------------------
library(LTFGRS)
library(dplyr)
library(igraph)

## -----------------------------------------------------------------------------
# load minnbreast data
data("minnbreast", package = "kinship2")

## ----echo=FALSE---------------------------------------------------------------
#printing a viewable version of the tibble:
rmarkdown::paged_table(minnbreast)

## -----------------------------------------------------------------------------
# create a (population) graph, with all individuals and all familial links
pop_graph = prepare_graph(.tbl = select(minnbreast, id, motherid, fatherid),
                          icol = "id",
                          fcol = "fatherid",
                          mcol = "motherid")

## -----------------------------------------------------------------------------
delete_edges(pop_graph, E(pop_graph)[which_mutual(pop_graph)])

## -----------------------------------------------------------------------------
# get family graphs for all probands in minnbreast data
family_graphs = get_family_graphs(pop_graph = pop_graph,
                                  ndegree = 10, # picking 10th degree relatives, to ensure we get all possible family members in the data
                                  proband_vec = as.character(minnbreast$id))
family_graphs


## -----------------------------------------------------------------------------
# extracting just the set of individuals labelled as "proband" in the minnbreast data
proband_ids = minnbreast %>% filter(proband == 1) %>%
  pull(id)

labelled_data = get_relations(family_graphs = family_graphs, family_id_vec = proband_ids)
labelled_data

## ----out.width="100%", fig.width=7.5, fig.height=7.5, fig.alt = "Plot of the identified relations per proband."----
p2 = Relation_per_proband_plot(labelled_relations = labelled_data, proband_vec = proband_ids)
p2 # can be modified with ggplot2 functions

