Generate Cofeature Matrices

Generate cofeature (feature by sample) matrices. The package utilizes ggplot2::geom_tile() to generate the matrix allowing for easy additions from the base matrix.

CRAN_Status_Badge Travis-CI BuildStatus Downloads permonth Totaldownloads Anaconda-ServerBadge SayThanks!

cofeatureR is an R Package that provides functions for plotting cofeature matrices (aka. feature-sample matrices). For example:


To get the released version from CRAN:


You can also get cofeatureR through conda:

conda install -c fongchun r-cofeaturer

To install the latest developmental version from github:


How to Use

The main function of cofeatureR is the plot_cofeature_mat function. It will produce a matrix plot (feature x sample) showing how the different “types” correlate between samples and features. This function only has one required input which is a data.frame containing 3 columns:

  • feature: Feature name
  • sampleID: Sample name
  • type: Type associated with the feature-sample.

For instance in the field of cancer genomics, we are often interested in knowing how different mutations (type) in different samples (sampleID) correlate between genes (feature). The input data.frame would have this format:

v1 <- c("RCOR1", "NCOR1", "LCOR", "RCOR1", "RCOR1", "RCOR1", "RCOR1")
v2 <- c("sampleA", "sampleC", "sampleB", "sampleC", "sampleA", "sampleC", "sampleC")
v3 <- c("Deletion", "Deletion", "SNV", "Rearrangement", "SNV", "Rearrangement", "SNV")
in.df <- dplyr::data_frame(feature = v1, sampleID = v2, type = v3)
feature sampleID type
RCOR1 sampleA Deletion
NCOR1 sampleC Deletion
LCOR sampleB SNV
RCOR1 sampleC Rearrangement
RCOR1 sampleA SNV
RCOR1 sampleC Rearrangement
RCOR1 sampleC SNV

This input data.frame can now be used as input into plot_cofeature_mat:

plot_cofeature_mat(in.df, tile.col = "black")

Notice how we are NOT restricted to having only one type per feature-sample. In other words, a feature-sample may have multiple types and plot_cofeature_mat will display all of the types.

There are many different parameters that can be passed into the plot_cofeature_mat for customization of the plot. For instance:

  • fill.colors: Custom colors for each type.
  • feature.order and Custom ordering of features and samples respectively.
  • tile.col: Add borders around each type.

Citing cofeatureR

#> file of package 'cofeatureR'
#> Warning in citation(package = "cofeatureR"): could not determine year for
#> 'cofeatureR' from package DESCRIPTION file

To cite package ‘cofeatureR’ in publications use:

Fong Chun Chan (NA). cofeatureR: Generate Cofeature Matrices. R package version 1.1.0.

A BibTeX entry for LaTeX users is

@Manual{, title = {cofeatureR: Generate Cofeature Matrices}, author = {Fong Chun Chan}, note = {R package version 1.1.0}, url = {}, }


cofeaturerR 1.1.1

  • Added the tibble R package as a dependency

cofeatureR 1.1.0

  • Added drop.x parameter
  • Added Travis-CI
  • Added ability to add dots to the cofeature matrices
  • Moved figures to the man/figures folder (#5)
  • Added the ability to specify width of borders (#4)

cofeatureR 1.0.1

  • Fixed an issue with sample labels not being displayed
  • Fixed a bug with the feature order and labeling not matching (#1)
  • Fixed a bug where feature and sample ids were being reversed in order in final output (#2)

cofeatureR 1.0.0

  • First major release of coFeatureR

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.1.1 by Fong Chun Chan, 3 years ago

Report a bug at

Browse source code at

Authors: Fong Chun Chan [aut, cre]

Documentation:   PDF Manual  

GPL-3 license

Imports ggplot2, dplyr, lazyeval, tibble

Suggests testthat

See at CRAN