,]
p_gof_s = p_gof_s[!is.na(p_gof_s$position),]
p_gof_s$Pathog_pred = rep('p_gof_s', nrow(p_gof_s))
p_lof_s = cv_df[cv_df$Clinical_Significance %in%
c('Pathogenic','Conflicting interpretations of pathogenicity') &
(cv_df$Gene == 'KCNJ2' | cv_df$KCNJx_eq_KCNJ2 == 1) &
cv_df$surface_score <= benign_sq[1] &
cv_df$surface_SE <= 0.5
,]
p_lof_s = p_lof_s[!is.na(p_lof_s$position),]
p_lof_s$Pathog_pred = rep('p_lof_s', nrow(p_lof_s))
p_gof_f = cv_df[cv_df$Clinical_Significance %in%
c('Pathogenic','Conflicting interpretations of pathogenicity') &
(cv_df$Gene == 'KCNJ2' | cv_df$KCNJx_eq_KCNJ2 == 1) &
cv_df$function_score >= benign_fq[2] &
cv_df$function_SE <= 0.5
,]
p_gof_f = p_gof_f[!is.na(p_gof_f$position),]
p_gof_f$Pathog_pred = rep('p_gof_f', nrow(p_gof_f))
p_lof_f = cv_df[cv_df$Clinical_Significance %in%
c('Pathogenic','Conflicting interpretations of pathogenicity') &
(cv_df$Gene == 'KCNJ2' | cv_df$KCNJx_eq_KCNJ2 == 1) &
cv_df$function_score <= benign_fq[1]  &
cv_df$function_SE <= 0.5
,]
p_lof_f = p_lof_f[!is.na(p_lof_f$position),]
p_lof_f$Pathog_pred = rep('p_lof_f', nrow(p_lof_f))
Pathog_pred = rbind(p_gof_s, p_gof_f, p_lof_s, p_lof_f)
p_unc = cv_df[cv_df$Clinical_Significance %in% c('Pathogenic') &
(cv_df$Gene == 'KCNJ2' | cv_df$KCNJx_eq_KCNJ2 == 1),]
p_unc = p_unc[!is.na(p_unc$position),]
p_unc  = setdiff(p_unc, subset(Pathog_pred, select = -c(Pathog_pred)))
p_unc$Pathog_pred = rep('p_unc', nrow(p_unc))
Pathog_pred = rbind(Pathog_pred, p_unc)
cv_df2 = cv_df
cv_df2$Gene[is.na(cv_df2$Gene)] = 'KCNJ2'
p_gof_s_a = cv_df2[(cv_df$Gene == 'KCNJ2' | cv_df$KCNJx_eq_KCNJ2 == 1) &
cv_df2$surface_score >= benign_sq[2]
,]
p_gof_s_a = p_gof_s_a[!is.na(p_gof_s_a$position),]
p_gof_s_a$Pathog_pred = rep('p_gof_s_a', nrow(p_gof_s_a))
p_lof_s_a = cv_df2[(cv_df$Gene == 'KCNJ2' | cv_df$KCNJx_eq_KCNJ2 == 1) &
cv_df2$surface_score <= benign_sq[1]
,]
p_lof_s_a = p_lof_s_a[!is.na(p_lof_s_a$position),]
p_lof_s_a$Pathog_pred = rep('p_lof_s_a', nrow(p_lof_s_a))
p_gof_f_a = cv_df2[(cv_df$Gene == 'KCNJ2' | cv_df$KCNJx_eq_KCNJ2 == 1) &
cv_df2$function_score >= benign_fq[2]
,]
p_gof_f_a = p_gof_f_a[!is.na(p_gof_f_a$position),]
p_gof_f_a$Pathog_pred = rep('p_gof_f_a', nrow(p_gof_f_a))
p_lof_f_a = cv_df2[(cv_df$Gene == 'KCNJ2' | cv_df$KCNJx_eq_KCNJ2 == 1) &
cv_df2$function_score <= benign_fq[1]
,]
p_lof_f_a = p_lof_f_a[!is.na(p_lof_f_a$position),]
p_lof_f_a$Pathog_pred = rep('p_lof_f_a', nrow(p_lof_f_a))
Pathog_pred_a = rbind(p_gof_s_a, p_gof_f_a, p_lof_s_a, p_lof_f_a)
Fig7c_pathopred = ggplot(Pathog_pred, aes(x=position, fill=Pathog_pred)) + geom_dotplot(method = 'histodot',binwidth = 1, size = 2, stackgroups = T) +
scale_x_continuous(breaks = seq(0,400,by=10)) +
coord_fixed(ratio = 8) +
ggtitle('Fig7c mechanism of know pathogenic mutations')
ggsave(paste0(fig_path,'Fig7c_pathopred_10per.pdf'), plot = Fig7c_pathopred)
Pathog_pred_wo_punc = Pathog_pred[!Pathog_pred$Pathog_pred == 'p_unc',]
n_pathog_expl = length(unique(droplevels(interaction(Pathog_pred_wo_punc$mutation, Pathog_pred_wo_punc$position))))
n_pathog_KCNJ2 = nrow(dbvar[dbvar$Clinical_Significance %in% c('Pathogenic','Conflicting interpretations of pathogenicity') & dbvar$Gene == 'KCNJ2',])
paste0(n_pathog_expl,' VUS of ',n_pathog_KCNJ2,' explained: ',n_pathog_expl / n_pathog_KCNJ2 *100,'%')
rep_pathog_expl = as.data.frame(summary(droplevels(as.factor(Pathog_pred_wo_punc$Mutation)), maxsum = 500))
rep_pathog_expl$ID = rownames(rep_pathog_expl)
colnames(rep_pathog_expl) = c('n_pred','ID')
rep_pathog_expl %>%
group_by(n_pred) %>%
summarise(no_rows = length(n_pred))
ts_ps = intersect(p_lof_s$Mutation, p_lof_s_a$Mutation)
ts_pf = intersect(p_lof_s$Mutation, p_lof_f_a$Mutation)
tf_ps = intersect(p_lof_f$Mutation, p_lof_s_a$Mutation)
tf_pf = intersect(p_lof_f$Mutation, p_lof_f_a$Mutation)
ttable = matrix(c(length(ts_ps),
length(ts_pf),
length(tf_ps),
length(tf_pf)),
nrow = 2,
dimnames = list(Pathogenic = c("LOS", "LOF"),
Predicted = c("LOS", "LOF")))
ttable
fisher.test(ttable, alternative = 'greater')
ClinSigSuppFig_row1 = ggplot(data = cv_kir21[cv_kir21$kir21_FLAG_resno %in% c(0:100) &
!is.na(cv_kir21$KCNJx_MUT_resid),],
aes(x = kir21_FLAG_resno, y = KCNJx_MUT_resid, fill = Clinical_Significance)) +
geom_tile(color = 'black', size = 0.1) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
scale_fill_identity(na.value = 'white') +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 3)
)
ClinSigSuppFig_row2 = ggplot(data = cv_kir21[cv_kir21$kir21_FLAG_resno %in% c(101:200) &
!is.na(cv_kir21$KCNJx_MUT_resid),],
aes(x = kir21_FLAG_resno, y = KCNJx_MUT_resid, fill = Clinical_Significance)) +
geom_tile(color = 'black', size = 0.1) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
scale_fill_identity(na.value = 'white') +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 3)
)
ClinSigSuppFig_row3 = ggplot(data = cv_kir21[cv_kir21$kir21_FLAG_resno %in% c(201:300) &
!is.na(cv_kir21$KCNJx_MUT_resid),],
aes(x = kir21_FLAG_resno, y = KCNJx_MUT_resid, fill = Clinical_Significance)) +
geom_tile(color = 'black', size = 0.1) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
scale_fill_identity(na.value = 'white') +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 3)
)
ClinSigSuppFig_row4 = ggplot(data = cv_kir21[cv_kir21$kir21_FLAG_resno %in% c(301:400) &
!is.na(cv_kir21$KCNJx_MUT_resid),],
aes(x = kir21_FLAG_resno, y = KCNJx_MUT_resid, fill = Clinical_Significance)) +
geom_tile(color = 'black', size = 0.1) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
scale_fill_identity(na.value = 'white') +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 3)
)
ClinSigSuppFig = ggarrange(ClinSigSuppFig_row1, ClinSigSuppFig_row2, ClinSigSuppFig_row3, ClinSigSuppFig_row4,
nrow = 4, ncol = 1)
annotate_figure(ClinSigSuppFig, fig.lab = 'ClinSigSuppFig')
ggsave(paste0(fig_path,'SuppFig1.pdf'), plot = ClinSigSuppFig)
print(paste0('Clinvar & Gnomad has data for ', round(sum(cv_kir21$Clinical_Significance != 'white') / nrow(cv_kir21),3) * 100, '% of KCNJ2 positions'))
print(paste0('Clinvar & Gnomad has data for ', round(1 - (sum(is.na(cv_kir21$Clinical_Significance)) / nrow(cv_kir21)),3) * 100, '% of KCNJ2 positions'))
Baseline_SuppFig_row1 = ggplot(data = baseline[baseline$position %in% c(1:100),],
aes(x = position, y = mutation, fill = log10(count))) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = '#FFA1E0') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
Baseline_SuppFig_row2 = ggplot(data = baseline[baseline$position %in% c(101:200),],
aes(x = position, y = mutation, fill = log10(count))) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = '#FFA1E0') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
Baseline_SuppFig_row3 = ggplot(data = baseline[baseline$position %in% c(201:300),],
aes(x = position, y = mutation, fill = log10(count))) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = '#FFA1E0') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
Baseline_SuppFig_row4 = ggplot(data = baseline[baseline$position %in% c(301:400),],
aes(x = position, y = mutation, fill = log10(count))) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = '#FFA1E0') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
Baseline_SuppFig = ggarrange(Baseline_SuppFig_row1, Baseline_SuppFig_row2, Baseline_SuppFig_row3, Baseline_SuppFig_row4,
nrow = 4, ncol = 1)
Baseline_SuppFig = annotate_figure(Baseline_SuppFig, fig.lab = 'Supplementary Figure 2a')
ggsave(paste0(fig_path,'SuppFig2a.pdf'), plot = Baseline_SuppFig)
baseline_ecdf = ggplot(baseline, aes(x=count)) + stat_ecdf() + scale_x_log10()
baseline_ecdf = annotate_figure(baseline_ecdf, fig.lab = 'Supplementary Figure 2b')
ggsave(paste0(fig_path,'SuppFig2b.pdf'), plot = baseline_ecdf)
NA_venn = ggVennDiagram::ggVennDiagram(list_NA) + scale_fill_distiller(palette = "Reds", direction = 1)
NA_venn = annotate_figure(NA_venn, fig.lab = 'Supplementary Figure 2c')
ggsave(paste0(fig_path,'SuppFig2c.pdf'), plot = NA_venn)
cor.prob(cor_NA[,3:5]) %>%
kbl(caption = 'SuppFig2d') %>%
kable_paper('hover', full_width = F, html_font = 'helvetica') %>%
save_kable(file = paste0(fig_path,'SuppFig2d.pdf'))
surf_rep_corr = ggarrange(d_neg_rep, d_low_rep, d_up_rep, d_high_rep,
ncol = 2, nrow = 2)
surf_rep_corr = annotate_figure(surf_rep_corr, fig.lab = 'Supplementay Figure 5')
ggsave(paste0(fig_path,'SuppFig5.pdf'), plot = surf_rep_corr)
surf_depth = ggplot(d_count_melt, aes(x = as.numeric(value), color = variable)) + stat_ecdf() +
facet_wrap(cond~.) +
scale_x_log10() +
geom_vline(xintercept = 30)
surf_depth = annotate_figure(surf_depth, fig.lab = 'Supplementay Figure 6')
ggsave(paste0(fig_path,'SuppFig6.pdf'), plot = surf_depth)
SurfSE_row1 = ggplot(data = kir21_surf[kir21_surf$position %in% c(1:100),],
aes(x = position, y = mutation, fill = surface_SE)) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = 'magenta') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
SurfSE_row2 = ggplot(data = kir21_surf[kir21_surf$position %in% c(101:200),],
aes(x = position, y = mutation, fill = surface_SE)) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = 'magenta') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
SurfSE_row3 = ggplot(data = kir21_surf[kir21_surf$position %in% c(201:300),],
aes(x = position, y = mutation, fill = surface_SE)) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = 'magenta') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
SurfSE_row4 = ggplot(data = kir21_surf[kir21_surf$position %in% c(301:400),],
aes(x = position, y = mutation, fill = surface_SE)) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = 'magenta') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
SurfSE_hist = ggplot(kir21_surf, aes(x=surface_SE)) +
geom_histogram(color="black", fill="white",bins=100) + theme_bw() +
ggtitle('SuppFig5b')
annotate_figure(SurfSE_hist, fig.lab = 'SuppFig7a')
ggsave(paste0(fig_path,'SuppFig7a.pdf'), plot = SurfSE_hist)
SurfSE_fig = ggarrange(SurfSE_row1, SurfSE_row2, SurfSE_row3, SurfSE_row4,
nrow = 4, ncol = 1)
annotate_figure(SurfSE_fig, fig.lab = 'SuppFig7b')
ggsave(paste0(fig_path,'SuppFig7b.pdf'), plot = SurfSE_fig)
func_rep_corr = ggarrange(f_neg_plot,
f_low_plot,
f_high_plot,
ncol = 2, nrow = 2)
func_rep_corr = annotate_figure(func_rep_corr, fig.lab = 'Supplementary Figure 8')
ggsave(paste0(fig_path,'SuppFig8.pdf'), plot = func_rep_corr)
func_depth = ggplot(f_count_melt, aes(x = as.numeric(value), color = variable)) + stat_ecdf() +
facet_wrap(cond~.) +
scale_x_log10() +
geom_vline(xintercept = 30)
func_depth = annotate_figure(func_depth, fig.lab = 'Supplementay Figure 9')
ggsave(paste0(fig_path,'SuppFig9.pdf'), plot = func_depth)
funcSE_hist = ggplot(kir21_func, aes(x=function_SE)) +
geom_histogram(color="black", fill="white",bins=100) + theme_bw() +
ggtitle('Supplementary Figure 10a')
ggsave(paste0(fig_path,'SuppFig10a.pdf'), plot = funcSE_hist)
funcSE_row1 = ggplot(data = kir21_func[kir21_func$position %in% c(1:100),],
aes(x = position, y = mutation, fill = function_SE)) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = 'magenta') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
funcSE_row2 = ggplot(data = kir21_func[kir21_func$position %in% c(101:200),],
aes(x = position, y = mutation, fill = function_SE)) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = 'magenta') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
funcSE_row3 = ggplot(data = kir21_func[kir21_func$position %in% c(201:300),],
aes(x = position, y = mutation, fill = function_SE)) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = 'magenta') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
funcSE_row4 = ggplot(data = kir21_func[kir21_func$position %in% c(301:400),],
aes(x = position, y = mutation, fill = function_SE)) +
geom_tile(aes(color = as.factor(is.wt)), size = 0.2) +
scale_fill_continuous_divergingx(palette = 'PuOr', mid = 0, rev=TRUE, na.value = 'magenta') +
scale_color_manual(values = c(NA,'green')) +
scale_x_continuous(breaks = seq(0, 400, by = 5)) +
coord_fixed(ratio = 1) +
theme(
panel.background = element_rect(fill = "white",
colour = "white",
size = 0.5, linetype = "solid"),
panel.grid.major = element_line(size = 0.5, linetype = 'solid',
colour = "lightgray"),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90, hjust = 1),
axis.text = element_text(size = 7)
)
funcSE = ggarrange(funcSE_row1, funcSE_row2, funcSE_row3, funcSE_row4,
nrow = 4, ncol = 1)
funcSE = annotate_figure(funcSE, fig.lab = 'Supplementary Figure 10')
ggsave(paste0(fig_path,'SuppFig10b.pdf'), plot = funcSE)
c_3spi = read.csv('./input_data/contact_3spi.txt', header = T, sep = '\t')
c_6m84 = read.csv('./input_data/contact_6m84.txt', header = T, sep = '\t')
c_3spi$sub_int = ifelse(c_3spi$Chain1 != c_3spi$Chain2, 1, 0)
c_6m84$sub_int = ifelse(c_6m84$Chain1 != c_6m84$Chain2, 1, 0)
colselect = c('Chain1','ResNum1','Chain2','ResNum2')
c1 = dplyr::intersect(c_3spi[c_3spi$sub_int == 1, colselect], c_6m84[c_6m84$sub_int == 1, colselect])
c2 = dplyr::intersect(c_3spi[c_3spi$sub_int == 0, colselect], c_6m84[c_6m84$sub_int == 0, colselect])
c1_rb = as.data.frame(rbind(as.matrix(c1[,c('Chain1','ResNum1')]),
as.matrix(c1[,c('Chain2','ResNum2')])))
colnames(c1_rb) = c('chain','resno')
c2_rb = as.data.frame(rbind(as.matrix(c2[,c('Chain1','ResNum1')]),
as.matrix(c2[,c('Chain2','ResNum2')])))
colnames(c2_rb) = c('chain','resno')
c1_rb_un = irk$Kir2_1_FLAG_Resno_mus[match(unique(as.numeric(c1_rb$resno)), irk$Kir2_2_Resno_NC)]
c1_rb_un = c1_rb_un[!is.na(c1_rb_un)]
c2_rb_un = irk$Kir2_1_FLAG_Resno_mus[match(unique(as.numeric(c2_rb$resno)), irk$Kir2_2_Resno_NC)]
c2_rb_un = c2_rb_un[!is.na(c2_rb_un)]
c3_total = union(c1_rb_un, c2_rb_un)
inter_int = setdiff(c3_total, c2_rb_un)
intra_int = setdiff(c3_total, c1_rb_un)
both_int = intersect(c1_rb_un,c2_rb_un)
df$inter_int = rep(0, nrow(df))
df$intra_int = rep(0, nrow(df))
df$both_int = rep(0, nrow(df))
df$inter_int[!is.na(match(df$position, inter_int))] = 1
df$intra_int[!is.na(match(df$position, intra_int))] = 1
df$both_int[!is.na(match(df$position, both_int))] = 1
df$ctd = ifelse(df$position %in% c(76:190), 0, 1)
df$ctd_contact = interaction(df$ctd,df$inter_int, df$intra_int, df$both_int)
ks.test(df$surface_score[df$ctd_contact == '1.0.1.0'], df$surface_score[df$ctd_contact == '1.0.0.1'])
ks.test(df$function_score[df$ctd_contact == '1.0.0.1'], df$function_score[df$ctd_contact == '1.0.1.0'])
contact_ecdf1 = ggplot(df[df$ctd == 1,], aes(x=surface_score, color = ctd_contact)) +
stat_ecdf() +
theme_classic()
contact_ecdf2 = ggplot(df[df$ctd == 1,], aes(x=function_score, color = ctd_contact)) + stat_ecdf() +
theme_classic()
contact_ecdf = ggarrange(contact_ecdf1, contact_ecdf2, nrow = 2, ncol = 1)
ggsave(paste0(fig_path,'SuppFig11.pdf'), plot = contact_ecdf)
ttable %>%
kbl(caption = 'SuppFig12') %>%
kable_paper('hover', full_width = F, html_font = 'helvetica') %>%
save_kable(file = paste0(fig_path,'SuppFig12.pdf'))
SuppTable1b = summary_table(d_count_melt, summaries = read_count_summary, by = c('variable','cond'))
SuppTable1b %>%
kbl(caption = 'SuppTable1b') %>%
kable_paper('hover', full_width = F, html_font = 'helvetica') %>%
save_kable(file = paste0(fig_path,'SuppTable1b.pdf'))
#SuppTable1c####
SuppTable1c = summary_table(f_count_melt, summaries = read_count_summary, by = c('variable','cond'))
SuppTable1c %>%
kbl(caption = 'SuppTable1c') %>%
kable_paper('hover', full_width = F, html_font = 'helvetica') %>%
save_kable(file = paste0(fig_path,'SuppTable1c.pdf'))
write.csv(dbvar, 'SuppTable2.csv')
dbvar_output = data.frame(
Variant_ID = seq(1:nrow(dbvar)),
Gene = dbvar$Gene,
Mutation = dbvar$Mutation,
Source = dbvar$Source,
Clinical_Significance = dbvar$Clinical_Significance,
ClinVar_ID = dbvar$ClinVar_ID,
Condition = dbvar$Condition,
kir21_resno = dbvar$kir21_resno,
kir21_resid = dbvar$kir21_resid,
kir21_FLAG_resno = dbvar$kir21_FLAG_resno,
KCNJx_eq_KCNJ2 = dbvar$KCNJx_eq_KCNJ2
)
write.csv(dbvar_output, paste0(fig_path,'SuppTable3.csv'))
VUSpred_output = data.frame(
Variant_ID = seq(1:nrow(VUSpred)),
Gene = VUSpred$Gene,
Mutation = VUSpred$Mutation,
Source = VUSpred$Source,
Clinical_Significance = VUSpred$Clinical_Significance,
ClinVar_ID = VUSpred$ClinVar_ID,
Condition = VUSpred$Condition,
kir21_resno = VUSpred$kir21_resno,
kir21_resid = VUSpred$kir21_resid,
kir21_FLAG_resno = VUSpred$position,
predicted_phenotype = VUSpred$VUSpred
)
write.csv(VUSpred_output, file = paste0(fig_path,'SuppTable4.csv'))
patho_pred_output = data.frame(
Variant_ID = seq(1:nrow(Pathog_pred_wo_punc)),
Gene = Pathog_pred_wo_punc$Gene,
Mutation = Pathog_pred_wo_punc$Mutation,
Source = Pathog_pred_wo_punc$Source,
Clinical_Significance = Pathog_pred_wo_punc$Clinical_Significance,
ClinVar_ID = Pathog_pred_wo_punc$ClinVar_ID,
Condition = Pathog_pred_wo_punc$Condition,
kir21_resno = Pathog_pred_wo_punc$kir21_resno,
kir21_resid = Pathog_pred_wo_punc$kir21_resid,
kir21_FLAG_resno = Pathog_pred_wo_punc$position,
predicted_phenotype = Pathog_pred_wo_punc$Pathog_pred
)
write.csv(patho_pred_output, file = paste0(fig_path,'SuppTable5.csv'))
