R/Cal_cor_pleiotropic_h2_single.R

Defines functions Cal_cor_pleiotropic_h2_single

Documented in Cal_cor_pleiotropic_h2_single

#' Compute single pleioh2g for target disease before correction with referred disease index in the rg matrix
#'
#' This function computes pleioh2g for the target disease before correction.
#'
#' @param rg_mat genetic correlation matrix.
#' @param h2g_T_single heritability for target diseases.
#' @param plei_h2_idx index of the target disease in the rg_mat.
#'
#' @return pleioh2g value for the target disease before correction
#' @export
#'
#' @examples
#' data(Results_full_rg)
#' data(h2_vector)
#' plei_h2_idx<-1
#' h2g_T_single<-h2_vector[plei_h2_idx]
#' Cal_cor_pleiotropic_h2_single(Results_full_rg,h2g_T_single,plei_h2_idx)

Cal_cor_pleiotropic_h2_single <- function(rg_mat,h2g_T_single,plei_h2_idx){
  n <- dim(rg_mat)[1]
  g2dg1 <- rg_mat[plei_h2_idx, ][-plei_h2_idx]
  cov_g2d <- rg_mat[-plei_h2_idx, -plei_h2_idx]
  h2g <- h2g_T_single*(t(g2dg1) %*% solve(rg_mat[-plei_h2_idx, -plei_h2_idx]) %*% g2dg1)
  return(h2g)
}

Try the pleioh2g package in your browser

Any scripts or data that you put into this service are public.

pleioh2g documentation built on March 9, 2026, 5:07 p.m.