heatmap.ipcaps: Plot heatmap from the result of IPCAPS

View source: R/heatmap.ipcaps.R

heatmap.ipcapsR Documentation

Plot heatmap from the result of IPCAPS

Description

Create a heatmap plot base on the top differentiators among groups and the input data.

Usage

heatmap.ipcaps(
  ipcaps_output,
  groups = NULL,
  min.member.in.group = 10,
  top.fst = 1000,
  fst.threshold = 0.01,
  is.cluster.snp = TRUE,
  ...
)

Arguments

ipcaps_output

the returned object from the ipcaps2 function.

groups

the number of groups or clusters to be used in a heatmap. Default = NULL.

min.member.in.group

a minimum number of member in the groups that will be used for top-marker selection and will be used for heatmap. Default = 10.

top.fst

a number to indicate the top markers according to Fst. The value can be set from 1 until the number of input markers. Defalt = 100.

fst.threshold

a threshold to cut off for Fst. First, fst.threshold is considered, then top.fst is considered. When the number of filtered markers is less than top.fst, top.fst is ignored. The value can be set between 0 and 1. Default = 0.

is.cluster.snp

the logic to indicate whether the rows of heatmap will be clustered or not. If is.cluster.snp is TRUE, the rows will be clustered to K groups and K represents the number of IPCAPS results by ignoring outliers (set by min.member.in.group). Default = TRUE.

Details

This function generates a graphical object which is compatible with the function ggsave from the R package ggplot2. Therefore you can save a plot to file via ggplot2::ggsave() from the return object. In order to see more parameters for ploting, also see pheatmap::pheatmap().

Value

pheatmap

Examples


# Load the required packages
library(ggplot2)
library(gridExtra)

# Importantly, bed file, bim file, and fam file are required
# Use the example files embedded in the package

BED.file <- system.file("extdata","ipcaps_example.bed",package="IPCAPS2")
LABEL.file <- system.file("extdata","ipcaps_example_individuals.txt.gz",package="IPCAPS2")

my.cluster <- ipcaps2(bed=BED.file,
                      label.file=LABEL.file,
                      lab.col=2,
                      out=tempdir(),
                      silence=TRUE,
                      no.rep=1)

# Show a plot
my.plot <- heatmap.ipcaps(my.cluster)

# To display gaps after each cluster, we can check the distribution of clustering result
table(my.cluster$cluster$group)
#1  2  3  4  5
#1  1  1 50 50
# You can calculate what to put the gabs by creating a vector for the location,
# by adding up the numbers according to the order of IPCAPS2_cluster in the heatmap
gaps_position = c(50, 100, 101, 102)
my.plot <- heatmap.ipcaps(my.cluster, gaps_col = gaps_position)

# Save the plot to file.
ggplot2::ggsave("heatmap.pdf", my.plot)

# To create multiple heatmap in one plot, for example
my.plot1 <- heatmap.ipcaps(my.cluster, main = "The first heatmap")
my.plot2 <- heatmap.ipcaps(my.cluster, main = "The second heatmap")
combined.plot <- gridExtra::grid.arrange(my.plot1$gtable,
                                         my.plot2$gtable,
                                         nrow=2)

# To save the combined plots to file
ggplot2::ggsave("combined_heatmap.pdf", combined.plot)

kridsadakorn/ipcaps2 documentation built on June 11, 2022, 8:35 p.m.