## ----column renaming------------------------------------------------------------------------------ rel_df <- data.frame( indId1 = c("110", "204"), indId2 = c("112", "205"), code = c(1, 2), family = c("1", "2") ) cols_ren_rel <- list( id1 = "indId1", id2 = "indId2", famid = "family" ) ## Rename columns rel old_cols <- as.vector(unlist(cols_ren_rel)) new_cols <- names(cols_ren_rel) cols_to_ren <- match(old_cols, names(rel_df)) names(rel_df)[cols_to_ren[!is.na(cols_to_ren)]] <- new_cols[!is.na(cols_to_ren)] print(rel_df) ## ----normalisation-------------------------------------------------------------------------------- library(Pedixplorer) data("sampleped") cols <- c("sex", "id", "avail") summary(sampleped[cols]) ped <- Pedigree(sampleped) summary(as.data.frame(ped(ped))[cols]) ## ----rel_df errors-------------------------------------------------------------------------------- rel_wrong <- rel_df rel_wrong$code[2] <- "A" df <- Pedigree(sampleped, rel_wrong) print(df) ## ----mcols---------------------------------------------------------------------------------------- ped <- Pedigree(sampleped) mcols(ped)[8:12] ## Add new columns as a threshold if identifiers of individuals superior ## to a given threshold for example mcols(ped)$idth <- ifelse(as.numeric(mcols(ped)$indId) < 200, "A", "B") mcols(ped)$idth ## ----pedigree methods----------------------------------------------------------------------------- ## We can change the family name based on an other column ped <- upd_famid_id(ped, mcols(ped)$idth) ## We can substract a given family pedA <- ped[famid(ped) == "A"] ## Plot it plot(pedA, cex = 0.5) ## Do a summary summary(pedA) ## Coerce it to a list as.list(pedA)[[1]][1:3] ## Shrink it to keep only the necessary information lst1_s <- shrink(pedA, max_bits = 10) plot(lst1_s$pedObj, cex = 0.5) ## Compute the kinship individuals matrix kinship(pedA)[1:10, 1:10] ## Get the useful individuals pedA <- useful_inds(pedA, informative = "AvAf") as.data.frame(ped(pedA))["useful"][1:10,] ## ------------------------------------------------------------------------------------------------- sessionInfo()