extract_rectangle: Extract rectangle from omics file, data.table, or matrix

View source: R/3.0_read_omics.R

extract_rectangleR Documentation

Extract rectangle from omics file, data.table, or matrix

Description

Extract rectangle from omics file, data.table, or matrix

Usage

extract_rectangle(x, ...)

## S3 method for class 'character'
extract_rectangle(
  x,
  rows = seq_len(nrows(x, sheet = sheet)),
  cols = seq_len(ncols(x, sheet = sheet)),
  verbose = FALSE,
  transpose = FALSE,
  drop = FALSE,
  sheet = 1,
  ...
)

## S3 method for class 'data.table'
extract_rectangle(
  x,
  rows = seq_len(nrow(x)),
  cols = seq_len(ncol(x)),
  transpose = FALSE,
  drop = FALSE,
  ...
)

## S3 method for class 'matrix'
extract_rectangle(
  x,
  rows = seq_len(nrow(x)),
  cols = seq_len(ncol(x)),
  transpose = FALSE,
  drop = FALSE,
  ...
)

Arguments

x

omics datafile or datatable

...

allow for S3 method dispatch

rows

numeric vector

cols

numeric vector

verbose

logical

transpose

logical

drop

logical

sheet

numeric or string

Value

matrix

Examples

# FROM FILE: extract_rectangle.character
#=======================================
   x <- system.file('extdata/atkin.metabolon.xlsx', package = 'autonomics')
   extract_rectangle(x, rows = 11:30, cols = 15:81, sheet = 2)[ 1:3, 1:3 ]  # exprs
   extract_rectangle(x, rows = 11:30, cols = 2,     sheet = 2)[ 1:3,     ]  # fids
   extract_rectangle(x, rows = 4,     cols = 15:81, sheet = 2)[    , 1:3 ]  # sids
   extract_rectangle(x, rows = 10:30, cols = 1:14,  sheet = 2)[ 1:3, 1:3 ]  # fdt
   extract_rectangle(x, rows = 1:10,  cols = 14:81, sheet = 2, transpose = TRUE)[1:3, 1:3] # sdt

# FROM MATRIX: extract_rectangle.matrix
#======================================
   x <- system.file('extdata/atkin.metabolon.xlsx', package = 'autonomics')
   x %<>% extract_rectangle(sheet = 2)
   extract_rectangle(x, rows = 11:30,  cols = 15:81, sheet = 2)[ 1:3, 1:3 ]  # exprs
   extract_rectangle(x, rows = 11:30,  cols = 2,     sheet = 2)[ 1:3,     ]  # fids
   extract_rectangle(x, rows = 4,      cols = 15:81, sheet = 2)[    , 1:3 ]  # sids
   extract_rectangle(x, rows = 10:30,  cols = 1:14,  sheet = 2)[ 1:3, 1:3 ]  # fdt
   extract_rectangle(x, rows = 1:10,   cols = 14:81, sheet = 2, transpose = TRUE)[1:3, 1:3] # sdt

bhagwataditya/importomics documentation built on Oct. 29, 2024, 3:19 p.m.