08.Compare_all_PTRS

Author

Natasha Santhanam

Published

February 7, 2022

Sumary PTRS performance vs Individual PTRS in Rats

Calculate Predicted Height in Rats using Lassosum PTRS weights

Match genes in weights file in humans to Rat expression

Filter for overlap

Filter for Genes with Human Ortholog

Generate predicted values for Height using all models

Compare Both Clump and Original Scale weights to Observed Height in Rats

clump_height <- readRDS(data.dir %&% "PTRS_weights/predicted_height_WB_spxcan2ptrs_clump.RDS")
orig_height <- readRDS(data.dir %&% "PTRS_weights/predicted_height_WB_spxcan2ptrs_original_scale.RDS")

weights <- weights %>% select(-c(gene_name))
n_genes_clump <- as.matrix(apply(weights, 2, function(x) sum(x != 0 )))

weights <- read_tsv(data.dir %&% "PTRS_weights/weight_files/spxcan2ptrs_original_scale.Standing_height.Whole_Blood.weights.tsv")
weights <- weights %>% select(-c(gene_name))
n_genes_orig <- as.matrix(apply(weights, 2, function(x) sum(x != 0 )))


pheno <- read_csv(data.dir %&% "Box_files/processed_obesity_rat_Palmer_phenotypes.csv") %>% dplyr::select(c(rat_rfid, bmi_bodylength_w_tail, bmi_bodylength_wo_tail, bodylength_w_tail, bodylength_wo_tail, tail_length)) 
pheno <- pheno %>% filter(!(rat_rfid  %in% all_rats$ID))

Create Dataframes with the correlation coefficient between trait in rats and ones predicted using PTRS from Humans

Naive PTRS for Rats

Already have weight files for Naive PTRS from G1000 Whole blood models - so just need to multiply by predicted expression in rats

filelist <- list.files(out.dir %&% "naive_PTRS/", pattern = ".tsv", full.names = TRUE)

for(fila in filelist) {
weights <- read_tsv(fila)
weights$gene = sapply(strsplit(weights$gene, "\\."), `[`, 1)
naive_pred_height <- fn_generate_trait(pred_expr, weights)
saveRDS(naive_pred_height, data.dir %&% "PTRS_weights/naive_PTRS/naive_PTRS_new_pred_height_" %&% substr(fila, 113, str_length(fila)-4) %&% ".RDS")
}

Calculate Correlation with Observed Height

filelist <- list.files(data.dir %&% "PTRS_weights/naive_PTRS/", full.names = TRUE)
naive_pred_height <- data.frame(ID = as.character())

for(fila in filelist) {
  df <- as.data.frame(readRDS(fila)) %>% mutate(ID = rownames(df)) 
  colnames(df)[1] <- substr(fila, 100, str_length(fila)- 4)
  naive_pred_height <- full_join(naive_pred_height, df, by = "ID")
}

tempo <- naive_pred_height[na.omit(match(bodylength_w_tail$rat_rfid, naive_pred_height$ID)), ]

naive_height <- data.frame(estimate = numeric(), pvalue = numeric(), conf.int.min = numeric(), conf.int.max = numeric(), model = character() )
tempo <- tempo %>% select(-c(ID))

for(i in 1:ncol(tempo)) {
  naive_height[i,1] <- cor.test(bodylength_w_tail$bodylength_w_tail, tempo[,i])$estimate
  naive_height[i,2] <- cor.test(bodylength_w_tail$bodylength_w_tail, tempo[,i])$p.value
  naive_height[i,3] <- cor.test(bodylength_w_tail$bodylength_w_tail, tempo[,i])$conf.int[1]
  naive_height[i,4] <- cor.test(bodylength_w_tail$bodylength_w_tail, tempo[,i])$conf.int[2]
  naive_height[i,5] <- colnames(tempo)[i]
}
No matching items