Giter Site home page Giter Site logo

ra's Introduction

The {ra} R package
A minimal TileDB-backed lazy multi-dimensional array implementation with metadata

GitHub R package version Lifecycle: experimental CRAN status

The {ra} R package provides a wrapper around the low-level {tiledb} API and {jsonlite}, to implement a minimal lazy multi-dimensional array with arbitrary metadata support.

The motivation for {ra} comes from the fact that the high-level {tiledb} API (square bracket subsetting and subassignment) for dense arrays is limited only to 2D for subarray writes, and 3D for subarray reads. Additionally, metadata support is limited to strings, while we can get arbitrarily complex metadata through the use of JSON.

Install

You can install the latest version of {ra} from GitHub with the following:

if (!require(pak)) install.packages("pak")
pak::pak("rogiersbart/ra")

Use

ra <- ra::ra(5, 4, 2)
dim(ra)
#> [1] 5 4 2

# read
ra[1:5,1:2,1:2]
#> , , 1
#> 
#>      [,1] [,2]
#> [1,]  255  255
#> [2,]  255  255
#> [3,]  255  255
#> [4,]  255  255
#> [5,]  255  255
#> 
#> , , 2
#> 
#>      [,1] [,2]
#> [1,]  255  255
#> [2,]  255  255
#> [3,]  255  255
#> [4,]  255  255
#> [5,]  255  255
ra[1,,]
#>      [,1] [,2]
#> [1,]  255  255
#> [2,]  255  255
#> [3,]  255  255
#> [4,]  255  255
ra[1]
#>      [,1] [,2]
#> [1,]  255  255
#> [2,]  255  255
#> [3,]  255  255
#> [4,]  255  255
ra[1, , 1]
#> [1] 255 255 255 255
ra[]
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]  255  255  255  255
#> [2,]  255  255  255  255
#> [3,]  255  255  255  255
#> [4,]  255  255  255  255
#> [5,]  255  255  255  255
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]  255  255  255  255
#> [2,]  255  255  255  255
#> [3,]  255  255  255  255
#> [4,]  255  255  255  255
#> [5,]  255  255  255  255

# write
ra[1,1,1] <- 0L
ra[3,1:4,2] <- rep(1, 4)
ra[,4, 2] <- rep(3, 5)
ra[]
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    0  255  255  255
#> [2,]  255  255  255  255
#> [3,]  255  255  255  255
#> [4,]  255  255  255  255
#> [5,]  255  255  255  255
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]  255  255  255    3
#> [2,]  255  255  255    3
#> [3,]    1    1    1    3
#> [4,]  255  255  255    3
#> [5,]  255  255  255    3

# squash
fs::dir_info(ra$path, recurse = TRUE)$size |> sum()
#> 14.6K
ra::squash(ra)
fs::dir_info(ra$path, recurse = TRUE)$size |> sum()
#> 5K

# metadata
ra::metadata(ra)
#> NULL
ra::metadata(ra) <- list(name = "Demo {ra} array", purpose = "Demonstrate use")
ra::metadata(ra)
#> $name
#> [1] "Demo {ra} array"
#> 
#> $purpose
#> [1] "Demonstrate use"

Note

Both {lazyarray} and its successor {filearray} provide similar functionality.

ra's People

Contributors

rogiersbart avatar

Watchers

 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.