setwd('/Users/zkoenig/Documents/hgdp_tgp_local/ADMIXTURE')
# reading in hgdp_1kGP metadata file which has metrics needed for annotating
metadata <- read_tsv('gnomad_meta_hgdp_tgp_v1.txt')
fam_file <- read_tsv('hgdp_1kg_plink_data/post_qc_ld_unrel_only.fam',
col_names=FALSE)
global_region_id <- metadata %>% select('s', 'hgdp_tgp_meta.Genetic.region')
# Removing the v3.1 from gnomAD samples in the id file so there are no NA
global_region_id$s <- gsub("v3.1::", "", global_region_id$s )
merge_fam <- left_join(x = fam_file, y = global_region_id, by=c('X2'='s'))
merge_fam <- merge_fam[,c(7, 2, 3, 4, 5, 6 )]
ind2pop <- merge_fam[1]
# Getting a table with all of the continent colors for plotting
plot_colors <- metadata %>% select('hgdp_tgp_meta.Continent.colors',
'hgdp_tgp_meta.Genetic.region')
plot_colors <- unique(plot_colors)
write.table(ind2pop, file = 'pong_files/ind2pop.txt', col.names = FALSE,
row.names = FALSE, sep = "\t", quote = FALSE)
write.table(merge_fam,
file = 'hgdp_1kg_plink_data/new_post_qc_ld_unrel_only.fam',
col.names = FALSE,
row.names = FALSE, sep = "\t", quote = FALSE)
library(dplyr)
library(ggplot2)
library(tidyr)
library(readr)
library(cowplot)
setwd('/Users/zkoenig/Documents/hgdp_tgp_local/ADMIXTURE')
# reading in hgdp_1kGP metadata file which has metrics needed for annotating
metadata <- read_tsv('gnomad_meta_hgdp_tgp_v1.txt')
fam_file <- read_tsv('hgdp_1kg_plink_data/post_qc_ld_unrel_only.fam',
col_names=FALSE)
global_region_id <- metadata %>% select('s', 'hgdp_tgp_meta.Genetic.region')
# Removing the v3.1 from gnomAD samples in the id file so there are no NA
global_region_id$s <- gsub("v3.1::", "", global_region_id$s )
merge_fam <- left_join(x = fam_file, y = global_region_id, by=c('X2'='s'))
merge_fam <- merge_fam[,c(7, 2, 3, 4, 5, 6 )]
ind2pop <- merge_fam[1]
# Getting a table with all of the continent colors for plotting
plot_colors <- metadata %>% select('hgdp_tgp_meta.Continent.colors',
'hgdp_tgp_meta.Genetic.region')
plot_colors <- unique(plot_colors)
write.table(ind2pop, file = 'pong_files/ind2pop.txt', col.names = FALSE,
row.names = FALSE, sep = "\t", quote = FALSE)
write.table(merge_fam,
file = 'hgdp_1kg_plink_data/new_post_qc_ld_unrel_only.fam',
col.names = FALSE,
row.names = FALSE, sep = "\t", quote = FALSE)
