Skip to content

Commit

Permalink
Merge pull request #95 from drieslab/dev
Browse files Browse the repository at this point in the history
Fix gh actions
  • Loading branch information
jiajic authored Nov 19, 2023
2 parents c6b3bd3 + 8ea8b6b commit dce5511
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 230 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
name: pkgdown

on:
push:
branches: [main, master]
Expand All @@ -9,8 +11,6 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
Expand All @@ -22,19 +22,35 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2
- name: Checkout repo for workflow access
uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
- name: Setup pandoc
uses: r-lib/actions/setup-pandoc@v2

- name: Setup R environment
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
- name: Set up dependencies (general)
uses: r-lib/actions/setup-r-dependencies@v2
env:
_R_CHECK_FORCE_SUGGESTS: false
_R_CHECK_RD_XREFS: false
with:
dependencies: '"hard"' # do not use suggested dependencies
extra-packages: any::pkgdown, local::.
needs: website

- name: Set up dependencies (GiottoData)
run: |
suppressWarnings({
remotes::install_github('drieslab/GiottoData@suite_modular', build = FALSE)
})
shell: Rscript {0}

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}
Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Suggests:
geometry,
GiottoData,
HDF5Array (>= 1.18.1),
raster,
remotes,
rhdf5,
rlang,
Expand Down
4 changes: 2 additions & 2 deletions R/methods-IDs.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ NULL
#' the single-cell level) and feature IDs of a giotto object or subobject
#' @aliases spatIDs featIDs
#' @param x an object
#' @param spat_unit (optional) specify which spatial unit
#' @param feat_type (optional) specify which feature type
#' @param ... additional parameters to pass
#' @include classes.R
#' @usage
Expand All @@ -29,6 +27,7 @@ NULL


#' @rdname spatIDs-generic
#' @param spat_unit (optional) specify which spatial unit
#' @export
setMethod('spatIDs', signature(x = 'giotto'),
function(x, spat_unit = NULL, ...) {
Expand Down Expand Up @@ -103,6 +102,7 @@ setMethod('spatIDs', signature(x = 'nnNetObj'),


#' @rdname spatIDs-generic
#' @param feat_type (optional) specify which feature type
#' @export
setMethod('featIDs', signature(x = 'giotto'),
function(x, feat_type = NULL, ...) {
Expand Down
81 changes: 29 additions & 52 deletions R/methods-coerce.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,14 @@
#' @family As coercion functions
NULL

#' @title Coerce to sp
#' @name as.sp
#' @title R spatial conversions
#' @name r_spatial_conversions
#' @param x The object to coerce
#' @param drop When TRUE, returned object will be the sp object instead of
#' wrapped in a `giottoPoints` or `giottoPolygon` object
#' @family As coercion functions
NULL

#' @title Coerce to sf
#' @name as.sf
#' @param x The object to coerce
#' @param drop When TRUE, returned object will be the sf object instead of
#' wrapped in a `giottoPoints` or `giottoPolygon` object
#' @family As coercion functions
NULL

#' @title Coerce to stars
#' @name as.stars
#' @param x The object to coerce
#' @param drop When TRUE, returned object will be the stars object instead of
#' wrapped in a `giottoPoints` or `giottoPolygon` object
#' @family As coercion functions
NULL

#' @title Coerce to terra
#' @name as.terra
#' @param x The object to coerce
#' @param drop When TRUE, returned object will be the terra object instead of
#' wrapped in a `giottoPoints` or `giottoPolygon` object
#' @family As coercion functions
NULL

# ---------------------------------------------------------------- #

Expand Down Expand Up @@ -102,36 +79,36 @@ as.data.table.giottoPoints <- function(x, ...) {
# * to sp ####
# Spatial class covers both SpatialPolygonsDataFrame and SpatialPointsDataFrame

#' @rdname as.sp
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sp', signature('sf'), function(x) {
GiottoUtils::package_check('sp')
as(x, "Spatial")
})

#' @rdname as.sp
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sp', signature('SpatVector'), function(x) {
GiottoUtils::package_check('sp')
GiottoUtils::package_check('raster') # needed for this conversion
as(x, "Spatial")
})

#' @rdname as.sp
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sp', signature('stars'), function(x) {
GiottoUtils::package_check('sp')
as(x, "Spatial")
})

#' @rdname as.sp
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sp', signature('Spatial'), function(x) {
GiottoUtils::package_check('sp')
x
})

#' @rdname as.sp
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sp', signature('giottoPolygon'), function(x, drop = TRUE) {
if (isTRUE(drop)) {
Expand All @@ -142,7 +119,7 @@ setMethod('as.sp', signature('giottoPolygon'), function(x, drop = TRUE) {
}
})

#' @rdname as.sp
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sp', signature('giottoPoints'), function(x, drop = TRUE) {
s <- as.sp(x[])
Expand All @@ -157,34 +134,34 @@ setMethod('as.sp', signature('giottoPoints'), function(x, drop = TRUE) {


# * to sf ####
#' @rdname as.sf
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sf', signature('SpatVector'), function(x) {
spatvector_to_sf(x)
})

#' @rdname as.sf
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sf', signature('Spatial'), function(x) {
GiottoUtils::package_check('sf')
sf::st_as_sf(x)
})

#' @rdname as.sf
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sf', signature('stars'), function(x) {
GiottoUtils::package_check('sf')
sf::st_as_sf(x)
})

#' @rdname as.sf
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sf', signature('sf'), function(x) {
GiottoUtils::package_check('sf')
x
})

#' @rdname as.sf
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sf', signature('giottoPolygon'),
function(x, drop = TRUE) {
Expand All @@ -197,7 +174,7 @@ setMethod('as.sf', signature('giottoPolygon'),
}
})

#' @rdname as.sf
#' @rdname r_spatial_conversions
#' @export
setMethod('as.sf', signature('giottoPoints'),
function(x, drop = TRUE) {
Expand All @@ -215,7 +192,7 @@ setMethod('as.sf', signature('giottoPoints'),

# st_as_stars does not handle SpatVector. Only SpatRaster
# however, conversions from sf work fine
#' @rdname as.stars
#' @rdname r_spatial_conversions
#' @export
setMethod('as.stars', signature('SpatVector'),
function(x) {
Expand All @@ -224,31 +201,31 @@ setMethod('as.stars', signature('SpatVector'),
stars::st_as_stars()
})

#' @rdname as.stars
#' @rdname r_spatial_conversions
#' @export
setMethod('as.stars', signature('sf'),
function(x) {
GiottoUtils::package_check('stars')
stars::st_as_stars(x)
})

#' @rdname as.stars
#' @rdname r_spatial_conversions
#' @export
setMethod('as.stars', signature('Spatial'),
function(x) {
GiottoUtils::package_check('stars')
stars::st_as_stars(x)
})

#' @rdname as.stars
#' @rdname r_spatial_conversions
#' @export
setMethod('as.stars', signature('stars'),
function(x) {
GiottoUtils::package_check('stars')
x
})

#' @rdname as.stars
#' @rdname r_spatial_conversions
#' @export
setMethod('as.stars', signature('giottoPolygon'),
function(x, drop = TRUE) {
Expand All @@ -260,7 +237,7 @@ setMethod('as.stars', signature('giottoPolygon'),
}
})

#' @rdname as.stars
#' @rdname r_spatial_conversions
#' @export
setMethod('as.stars', signature('giottoPoints'),
function(x, drop = TRUE) {
Expand All @@ -276,21 +253,21 @@ setMethod('as.stars', signature('giottoPoints'),

# * to terra ####

#' @rdname as.terra
#' @rdname r_spatial_conversions
#' @export
setMethod('as.terra', signature('SpatVector'),
function(x) {
x
})

#' @rdname as.terra
#' @rdname r_spatial_conversions
#' @export
setMethod('as.terra', signature('sf'),
function(x) {
terra::vect(x)
})

#' @rdname as.terra
#' @rdname r_spatial_conversions
#' @param type whether data is 'vector' or 'raster'
#' @export
setMethod('as.terra', signature('stars'),
Expand All @@ -314,25 +291,25 @@ setMethod('as.terra', signature('stars'),
return(x)
})

#' @rdname as.terra
#' @rdname r_spatial_conversions
#' @export
setMethod('as.terra', signature('Spatial'), function(x) {
terra::vect(x)
})

#' @rdname as.terra
#' @rdname r_spatial_conversions
#' @export
setMethod('as.terra', signature('giottoPolygon'),
function(x, drop = TRUE, ...) {
function(x, drop = TRUE) {
if (isTRUE(drop)) {
return(as.terra(x[], ...))
return(as.terra(x[]))
} else {
x <- do_gpoly(x = x, what = as.terra, args = list(...))
x <- do_gpoly(x = x, what = as.terra, args = list())
return(x)
}
})

#' @rdname as.terra
#' @rdname r_spatial_conversions
#' @export
setMethod('as.terra', signature('giottoPoints'),
function(x, drop = TRUE) {
Expand Down
5 changes: 1 addition & 4 deletions man/as.data.table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 0 additions & 41 deletions man/as.sf.Rd

This file was deleted.

Loading

0 comments on commit dce5511

Please sign in to comment.