Learn R Programming

⚠️There's a newer version (1.6.1) of this package.Take me there.

bigstatsr

R package {bigstatsr} provides functions for fast statistical analysis of large-scale data encoded as matrices. The package can handle matrices that are too large to fit in memory thanks to memory-mapping to binary files on disk. This is very similar to the format big.matrix provided by R package {bigmemory}, which is no longer used by this package (see the corresponding vignette).

LIST OF FEATURES

Note that most of the algorithms of this package don't handle missing values.

Installation

# For the current development version
devtools::install_github("privefl/bigstatsr")

Small example

library(bigstatsr)

# Create the data on disk
X <- FBM(5e3, 10e3, backingfile = "test")$save()
# If you open a new session you can do
X <- big_attach("test.rds")

# Fill it by chunks with random values
U <- matrix(0, nrow(X), 5); U[] <- rnorm(length(U))
V <- matrix(0, ncol(X), 5); V[] <- rnorm(length(V))
NCORES <- nb_cores()
# X = U V^T + E
big_apply(X, a.FUN = function(X, ind, U, V) {
  X[, ind] <- tcrossprod(U, V[ind, ]) + rnorm(nrow(X) * length(ind))
  NULL  ## you don't want to return anything here
}, a.combine = 'c', ncores = NCORES, U = U, V = V)
# Check some values
X[1:5, 1:5]

# Compute first 10 PCs
obj.svd <- big_randomSVD(X, fun.scaling = big_scale(), 
                         k = 10, ncores = NCORES)
plot(obj.svd)

# Cleanup
unlink(paste0("test", c(".bk", ".rds")))

Learn more with this introduction to package {bigstatsr}.

Input format

As inputs, package {bigstatsr} uses Filebacked Big Matrices (FBM).

To memory-map character text files, see package {mmapcharr}.

Bug report / Help

Please open an issue if you find a bug. If you want help using {bigstatsr}, please post on Stack Overflow with the tag bigstatsr (not yet created). How to make a great R reproducible example?

Use cases

Parallelisation

Package {bigstatsr} uses package {foreach} for its parallelization tasks. Learn more on parallelism with {foreach} with this tuto.

Large datasets

Copy Link

Version

Install

install.packages('bigstatsr')

Monthly Downloads

3,154

Version

0.6.2

License

GPL-3

Maintainer

Florian Privé

Last Published

August 17th, 2018

Functions in bigstatsr (0.6.2)

Replace

Create an Implementation of [<- For Custom Matrix-Like Types
FBM.code256-class

Class FBM.code256
FBM-class

Class FBM
COPY_biglasso_main

Sparse regression path
FBM-methods

Methods for the FBM class
FBM.code256-methods

Methods for the FBM.code256 class
big_spLogReg

Sparse logistic regression
big_parallelize

Split-parApply-Combine
big_tcrossprodSelf

Tcrossprod
big_counts

Counts
big_cprodMat

Cross-product with a matrix
big_copy

Copy a Filebacked Big Matrix
big_transpose

Transposition
big_SVD

Partial SVD
block_size

Determine a correct value for the block.size parameter
without_downcast_warning

Temporarily disable downcast warning
big_cprodVec

Cross-product with a vector
get_beta

Combine sets of coefficients
big_cor

Correlation
big_crossprodSelf

Crossprod
big_read

Read a file
big_scale

Some scaling functions
big_apply

Split-Apply-Combine
big_prodMat

Product with a matrix
plot.big_SVD

Plot method
plot.mhtest

Plot method
nb_cores

Recommended number of cores to use
predict.mhtest

Predict method
big_write

Write a file
bigstatsr-package

bigstatsr: Statistical Tools for Filebacked Big Matrices
predict.big_sp

Predict method
rows_along

Sequence generation
predict.big_sp_best_list

Predict method
big_prodVec

Product with a vector
big_randomSVD

Randomized partial SVD
big_univLinReg

Column-wise linear regression
big_univLogReg

Column-wise logistic regression
pasteLoc

Get coordinates
sub_bk

Replace extension 'bk'
theme_bigstatsr

Theme ggplot2
plus

Add
predict.big_SVD

Scores of PCA
AUC

AUC
asPlotlyText

Plotly text
COPY_biglasso_part

Train one model
big_attach

Attach a Filebacked Big Matrix
Extract

Create an Implementation of [ For Custom Matrix-Like Types
big_spLinReg

Sparse linear regression
big_colstats

Standard univariate statistics