GithubHelp home page GithubHelp logo

neato-nick / counttofpkm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aalhendi1707/counttofpkm

0.0 0.0 0.0 942 KB

Convert Counts to Fragments per Kilobase of Transcript per Million (FPKM)

License: GNU General Public License v3.0

R 100.00%

counttofpkm's Introduction

countToFPKM

CRAN_Status_Badge CRAN_Downloads_Badge

Overview

The 'countToFPKM' package provides a robust function to convert the feature counts of paired-end RNA-Seq into FPKM normalised values by library size and feature effective length. Implements the algorithm described in Trapnell,C. et al. (2010).

This package includes two functions:

  • fpkm()
  • fpkmheatmap()

The fpkm() function converts the feature counts into FPKM values, it requires three arguments to return FPKM as numeric matrix normalized by library size and feature length:

  • counts a numeric matrix of raw feature counts.
  • featureLength a numeric vector with feature lengths that can be obtained using
    biomaRt package.
  • meanFragmentLength a numeric vector with mean fragment lengths, which can be calculated using the
    CollectInsertSizeMetrics(Picard) tool.

The fpkmheatmap() function provides users with a robust method to generate a FPKM heatmap plot of the highly variable features in RNA-Seq dataset. It takes an FPKM numeric matrix which can be obtained using fpkm() function as input. By default using Pearson correlation - 1 to measure the distance between features, and Spearman correlation -1 for clustering of samples. By default log10 transformation of (FPKM+1) is applied to make variation similar across orders of magnitude. It uses the var() function to identify the highly variable features. It then uses Heatmap() function from the 'ComplexHeatmap' package to generate a heatmap plot.

To cite the R package 'countToFPKM' in publications use:

"Alhendi, A.S.N. (2019). countToFPKM: Convert Counts to Fragments per Kilobase of Transcript per Million (FPKM). R package version 1.0.0. https://CRAN.R-project.org/package=countToFPKM"

Installation

## Install dependencies
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("ComplexHeatmap")

## Stable version, install countToFPKM from CRAN
install.packages("countToFPKM")

## Lastest version, install countToFPKM from GitHub
if(!require(devtools)) install.packages("devtools")
devtools::install_github("AAlhendi1707/countToFPKM", build_vignettes = TRUE)

Usage example

library(countToFPKM)

file.readcounts <- system.file("extdata", "RNA-seq.read.counts.csv", package="countToFPKM")
file.annotations <- system.file("extdata", "Biomart.annotations.hg38.txt", package="countToFPKM")
file.sample.metrics <- system.file("extdata", "RNA-seq.samples.metrics.txt", package="countToFPKM")

# Import the read count matrix data into R.
counts <- as.matrix(read.csv(file.readcounts))

# Import feature annotations. 
# Assign feature lenght into a numeric vector.
gene.annotations <- read.table(file.annotations, sep="\t", header=TRUE)
featureLength <- gene.annotations$length

# Import sample metrics. 
# Assign mean fragment length into a numeric vector.
samples.metrics <- read.table(file.sample.metrics, sep="\t", header=TRUE)
meanFragmentLength <- samples.metrics$meanFragmentLength

# Return FPKM into a numeric matrix.
fpkm_matrix <- fpkm (counts, featureLength, meanFragmentLength)

# Plot log10(FPKM+1) heatmap of top 30 highly variable features
fpkmheatmap(fpkm_matrix, topvar=30, showfeaturenames=TRUE, return_log = TRUE)

Contributing

Please submit an issue to report bugs or ask questions.

Please contribute bug fixes or new features with a pull request to this repository.

counttofpkm's People

Contributors

aalhendi1707 avatar neato-nick avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.