This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to plot heatmap in r for all the gene across tissues to see distribution of snps

I have a dataframe which looks like this:

dput(chr22_gene[,1:49])
structure(c(0.0531016390078734, -0.00413407782001034, -0.035434632568444, 
0.00968736935965742, 0, 0, 0, 0, 0, 0, 0, -0.1983546, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5.54054634049041e-06, -1.02538094713665e-06, 
1.75405521957808e-07, 2.81925504836742e-08, -0.00286734456709225, 
0.00467948313596414, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0104604233349395, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0259856283860652, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0107519090954185, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0147898755312336, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0314582291188165, 0, 0, 0.00500515393772989, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), dim = c(11L, 49L), dimnames = list(
    c("rs1041770_ENSG00000283633.1", "rs12628452_ENSG00000283633.1", 
    "rs915675_ENSG00000283633.1", "rs11089130_ENSG00000283633.1", 
    "rs738820_ENSG00000240972.1", "rs7290144_ENSG00000240972.1", 
    "rs2298386_ENSG00000240972.1", "rs3788374_ENSG00000240972.1", 
    "rs9830_ENSG00000240972.1", "rs5760687_ENSG00000240972.1", 
    "rs6003388_ENSG00000240972.1"), c("en_Adipose_Subcutaneous.db", 
    "en_Adipose_Visceral_Omentum.db", "en_Adrenal_Gland.db", 
    "en_Artery_Aorta.db", "en_Artery_Coronary.db", "en_Artery_Tibial.db", 
    "en_Brain_Amygdala.db", "en_Brain_Anterior_cingulate_cortex_BA24.db", 
    "en_Brain_Caudate_basal_ganglia.db", "en_Brain_Cerebellar_Hemisphere.db", 
    "en_Brain_Cerebellum.db", "en_Brain_Cortex.db", "en_Brain_Frontal_Cortex_BA9.db", 
    "en_Brain_Hippocampus.db", "en_Brain_Hypothalamus.db", "en_Brain_Nucleus_accumbens_basal_ganglia.db", 
    "en_Brain_Putamen_basal_ganglia.db", "en_Brain_Spinal_cord_cervical_c.1.db", 
    "en_Brain_Substantia_nigra.db", "en_Breast_Mammary_Tissue.db", 
    "en_Cells_Cultured_fibroblasts.db", "en_Cells_EBV.transformed_lymphocytes.db", 
    "en_Colon_Sigmoid.db", "en_Colon_Transverse.db", "en_Esophagus_Gastroesophageal_Junction.db", 
    "en_Esophagus_Mucosa.db", "en_Esophagus_Muscularis.db", "en_Heart_Atrial_Appendage.db", 
    "en_Heart_Left_Ventricle.db", "en_Kidney_Cortex.db", "en_Liver.db", 
    "en_Lung.db", "en_Minor_Salivary_Gland.db", "en_Muscle_Skeletal.db", 
    "en_Nerve_Tibial.db", "en_Ovary.db", "en_Pancreas.db", "en_Pituitary.db", 
    "en_Prostate.db", "en_Skin_Not_Sun_Exposed_Suprapubic.db", 
    "en_Skin_Sun_Exposed_Lower_leg.db", "en_Small_Intestine_Terminal_Ileum.db", 
    "en_Spleen.db", "en_Stomach.db", "en_Testis.db", "en_Thyroid.db", 
    "en_Uterus.db", "en_Vagina.db", "en_Whole_Blood.db")))

I want to plot a heatmap to see how many rsids or snps are present for one gene across tissues and their magnitude and their direction So basically let say for one gene: it has many rsids, I want to have one color correspond to snps, and one color to correspond to different magnitude let say for this gene it has the same rsid across 2 tissues, then their value is different so these two tissues should have different color scale and if the rsid between two tissue for the gene is in different direction one is +ve and one is -ve then different color like tissue 1 which has rsid in +ve it should be green and the other tissue with the same rsid for the same gene has -ve value then it should be yellow.

I used this code:

chr22_gene <- as.matrix(chr22_gene)
heatmap(chr22_gene)

enter image description here

snp r heatmap

0 answers

No answers yet.

Log in to answer this question.