Skip to content

Commit

Permalink
Merge pull request #44 from jiajic/master
Browse files Browse the repository at this point in the history
Merge suite_modular into master
  • Loading branch information
jiajic authored Nov 29, 2023
2 parents 46019dd + b271fd4 commit fa2ea87
Show file tree
Hide file tree
Showing 53 changed files with 317 additions and 182 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
^.*\.Rproj$
^\.Rproj\.user$
^_pkgdown\.yml$
^docs$
^pkgdown$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3

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

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
clean: false
branch: gh-pages
folder: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.RData
.Ruserdata
*.DS_Store
docs
16 changes: 12 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
Package: GiottoData
Type: Package
Title: Datasets for Giotto
Version: 0.2.5
Version: 0.2.6.2
Author: c(
person("Ruben", "Dries", email = "rubendries@gmail.com",
role = c("aut", "cre"))
)
Maintainer: Ruben Dries <rubendries@gmail.com>
Description: Stores information and scripts to work with, or load various
different spatial datasets that can be used with the Giotto Suite workflow.
Also contains example mini Giotto subobjects
Also contains example mini Giotto subobjects.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
URL: https://drieslab.github.io/GiottoData/, https://github.com/drieslab/GiottoData
BugReports: https://github.com/drieslab/GiottoData/issues
Depends:
R (>= 3.5.0),
Giotto (>= 3.0.0)
GiottoClass,
GiottoUtils,
utils (>= 3.5.0)
Imports:
utils (>= 3.5.0),
data.table (>= 1.14.0),
Suggests:
GiottoVisuals,
Giotto,
terra (>= 1.5-12)
Remotes:
drieslab/GiottoClass,
drieslab/GiottoUtils,
drieslab/Giotto@suite_modular
RoxygenNote: 7.2.3
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export(listSODBDatasetNames)
export(listSubObjectMini)
export(loadGiottoMini)
export(loadSubObjectMini)
import(GiottoClass)
import(GiottoUtils)
import(data.table)
import(ggplot2)
import(utils)
importClassesFrom(data.table,data.table)
91 changes: 37 additions & 54 deletions R/dataset_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,34 @@ loadGiottoMini = function(dataset = c('visium', 'seqfish', 'starmap', 'vizgen',

dataset = match.arg(dataset, choices = c('visium', 'seqfish', 'starmap', 'vizgen', 'cosmx', 'spatialgenomics'))


if(dataset == 'visium') {
mini_gobject = Giotto::loadGiotto(path_to_folder = system.file('/Mini_datasets/Visium/VisiumObject/', package = 'GiottoData'),
python_path = python_path,
reconnect_giottoImage = FALSE)
}


if(dataset == 'vizgen') {
mini_gobject = Giotto::loadGiotto(path_to_folder = system.file('/Mini_datasets/Vizgen/VizgenObject/', package = 'GiottoData'),
python_path = python_path,
reconnect_giottoImage = FALSE)
}

if(dataset == 'cosmx') {
mini_gobject = Giotto::loadGiotto(path_to_folder = system.file('/Mini_datasets/CosMx/CosMxObject/', package = 'GiottoData'),
python_path = python_path,
reconnect_giottoImage = FALSE)
}


if(dataset == 'seqfish') {
Giotto:::wrap_msg('To be implemented \n')
}

if(dataset == 'starmap') {
mini_gobject = Giotto::loadGiotto(path_to_folder = system.file('/Mini_datasets/3D_starmap/3DStarmapObject/', package = 'GiottoData'),
python_path = python_path)
}

if(dataset == 'spatialgenomics') {
mini_gobject = Giotto::loadGiotto(path_to_folder = system.file('/Mini_datasets/SpatialGenomics/SpatialGenomicsObject/', package = 'GiottoData'),
python_path = python_path)
}
mini_gobject = switch(
dataset,
'visium' = loadGiotto(path_to_folder = system.file('/Mini_datasets/Visium/VisiumObject/', package = 'GiottoData'),
python_path = python_path,
reconnect_giottoImage = FALSE),
'vizgen' = loadGiotto(path_to_folder = system.file('/Mini_datasets/Vizgen/VizgenObject/', package = 'GiottoData'),
python_path = python_path,
reconnect_giottoImage = FALSE),
'cosmx' = loadGiotto(path_to_folder = system.file('/Mini_datasets/CosMx/CosMxObject/', package = 'GiottoData'),
python_path = python_path,
reconnect_giottoImage = FALSE),
'seqfish' = {
wrap_msg('To be implemented \n')
return(invisible(NULL)) # exit early
},
'starmap' = loadGiotto(path_to_folder = system.file('/Mini_datasets/3D_starmap/3DStarmapObject/', package = 'GiottoData'),
python_path = python_path),
'spatialgenomics' = loadGiotto(path_to_folder = system.file('/Mini_datasets/SpatialGenomics/SpatialGenomicsObject/', package = 'GiottoData'),
python_path = python_path)
)


# 1. change default instructions
identified_python_path = set_giotto_python_path(python_path = python_path)
print(identified_python_path)
# Only mini object-specific instructions should be updated here. The python
# path update was taken care of inside of `loadGiotto()`
mini_gobject = changeGiottoInstructions(gobject = mini_gobject,
params = c('show_plot', 'return_plot', 'save_plot', 'save_dir'),
new_values = c(TRUE, FALSE, FALSE, NA)
#params = c('python_path', 'show_plot', 'return_plot', 'save_plot', 'save_dir'),
#new_values = c(identified_python_path, TRUE, FALSE, FALSE, getwd())
)
new_values = c(TRUE, FALSE, FALSE, NA))

return(mini_gobject)

Expand Down Expand Up @@ -125,7 +108,7 @@ getSpatialDataset = function(dataset = c('ST_OB1',
'sg_mini_kidney'))

# check operating system first
os_specific_system = Giotto:::get_os()
os_specific_system = get_os()

#if(os_specific_system == 'windows') {
# stop('This function is currently not supported on windows systems,
Expand Down Expand Up @@ -169,20 +152,20 @@ getSpatialDataset = function(dataset = c('ST_OB1',
selection = datasets_file[['dataset']] == sel_dataset
selected_dataset_info = datasets_file[selection,]
if(verbose) {
Giotto:::wrap_msg('Selected dataset links for: ', sel_dataset, ' \n \n')
wrap_msg('Selected dataset links for: ', sel_dataset, ' \n \n')
print(selected_dataset_info)
}



# get url to expression matrix and download
if(verbose) {
Giotto:::wrap_msg("\n \n Download expression matrix: \n")
wrap_msg("\n \n Download expression matrix: \n")
}
expr_matrix_url = selected_dataset_info[['expr_matrix']]

if(expr_matrix_url == "") {
Giotto:::wrap_msg('\n No expression found, skip this step \n')
wrap_msg('\n No expression found, skip this step \n')
} else {

expr_matrix_url = unlist(strsplit(expr_matrix_url, split = '\\|'))
Expand All @@ -192,7 +175,7 @@ getSpatialDataset = function(dataset = c('ST_OB1',
mydestfile = paste0(directory,'/', myfilename)

if(dryrun) {
Giotto:::wrap_msg("utils::download.file(url = ", url, ", destfile = ", mydestfile, ", ...)")
wrap_msg("utils::download.file(url = ", url, ", destfile = ", mydestfile, ", ...)")
} else {
utils::download.file(url = url, destfile = mydestfile, ...)
}
Expand All @@ -207,13 +190,13 @@ getSpatialDataset = function(dataset = c('ST_OB1',

# get url to spatial locations and download
if(verbose) {
Giotto:::wrap_msg("\n \n Download spatial locations: \n")
wrap_msg("\n \n Download spatial locations: \n")
}

spatial_locs_url = selected_dataset_info[['spatial_locs']]

if(spatial_locs_url == "") {
Giotto:::wrap_msg('\n No spatial locations found, skip this step \n')
wrap_msg('\n No spatial locations found, skip this step \n')
} else {

spatial_locs_url = unlist(strsplit(spatial_locs_url, split = '\\|'))
Expand All @@ -223,7 +206,7 @@ getSpatialDataset = function(dataset = c('ST_OB1',
mydestfile = paste0(directory,'/', myfilename)

if(dryrun) {
Giotto:::wrap_msg("utils::download.file(url = ", url, ", destfile = ", mydestfile, ", ...)")
wrap_msg("utils::download.file(url = ", url, ", destfile = ", mydestfile, ", ...)")
} else {
utils::download.file(url = url, destfile = mydestfile, ...)
}
Expand All @@ -236,14 +219,14 @@ getSpatialDataset = function(dataset = c('ST_OB1',

# get url(s) to additional metadata files and download
if(verbose) {
Giotto:::wrap_msg("\n \n Download metadata: \n")
wrap_msg("\n \n Download metadata: \n")
}

#metadata_url = selected_dataset_info[['metadata']][[1]]
metadata_url = selected_dataset_info[['metadata']]

if(metadata_url == "") {
Giotto:::wrap_msg('\n No metadata found, skip this step \n')
wrap_msg('\n No metadata found, skip this step \n')
} else {

metadata_url = unlist(strsplit(metadata_url, split = '\\|'))
Expand All @@ -253,7 +236,7 @@ getSpatialDataset = function(dataset = c('ST_OB1',
mydestfile = paste0(directory,'/', myfilename)

if(dryrun) {
Giotto:::wrap_msg("utils::download.file(url = ", url, ", destfile = ", mydestfile, ", ...)")
wrap_msg("utils::download.file(url = ", url, ", destfile = ", mydestfile, ", ...)")
} else {
utils::download.file(url = url, destfile = mydestfile, ...)
}
Expand All @@ -269,11 +252,11 @@ getSpatialDataset = function(dataset = c('ST_OB1',
spatial_seg_url = selected_dataset_info[['segmentations']]

if(spatial_seg_url == "") {
# Giotto:::wrap_msg('\n No segmentations found, skip this step \n')
# wrap_msg('\n No segmentations found, skip this step \n')
} else {

if(verbose) {
Giotto:::wrap_msg("\n \n Download segmentations: \n")
wrap_msg("\n \n Download segmentations: \n")
}

spatial_seg_url = unlist(strsplit(spatial_seg_url, split = '\\|'))
Expand All @@ -283,7 +266,7 @@ getSpatialDataset = function(dataset = c('ST_OB1',
mydestfile = paste0(directory,'/', myfilename)

if(dryrun) {
Giotto:::wrap_msg("utils::download.file(url = ", url, ", destfile = ", mydestfile, ", ...)")
wrap_msg("utils::download.file(url = ", url, ", destfile = ", mydestfile, ", ...)")
} else {
utils::download.file(url = url, destfile = mydestfile, ...)
}
Expand Down
5 changes: 5 additions & 0 deletions R/package_imports.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#' @import GiottoClass
#' @import GiottoUtils
#' @importClassesFrom data.table data.table
#' @import utils
NULL
25 changes: 17 additions & 8 deletions R/test_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#' is available (see \code{\link{listSubObjectMini}})
#' @export
loadSubObjectMini = function(x, idx = 1L) {

# declare data.table variables
type = index = path = NULL

avail_obj_dt = list_subobject_mini()
data_path = avail_obj_dt[type == x & index == idx, path]
Expand All @@ -16,23 +19,23 @@ loadSubObjectMini = function(x, idx = 1L) {

# wrapped objects
if(x %in% c('giottoPoints', 'giottoPolygon')) {
load_data = terra::vect(load_data)
load_data = GiottoClass::vect(load_data)
}

if(x == 'giottoLargeImage') {
original_path = load_data@file_path
new_path = gsub(pattern = '.*[/]GiottoData/', replacement = '', x = original_path)
new_path = paste0(gDataDir(), new_path)
load_data = Giotto:::reconnect_giottoLargeImage(giottoLargeImage = load_data,
image_path = new_path)
load_data = GiottoClass::reconnect_giottoLargeImage(giottoLargeImage = load_data,
image_path = new_path)
}

if(x == 'giottoImage') {
original_path = load_data@file_path
new_path = gsub(pattern = '.*[/]GiottoData/', replacement = '', x = original_path)
new_path = paste0(gDataDir(), new_path)
load_data = Giotto:::reconnect_giottoImage_MG(giottoImage = load_data,
image_path = new_path)
load_data = GiottoClass::reconnect_giottoImage_MG(giottoImage = load_data,
image_path = new_path)
}

return(load_data)
Expand All @@ -49,6 +52,9 @@ loadSubObjectMini = function(x, idx = 1L) {
#' @param x subobject type (NULL lists all subobject types)
#' @export
listSubObjectMini = function(x = NULL) {

# declare data.table variables
path = type = NULL

avail_obj_dt = list_subobject_mini()
avail_obj_dt_show = copy(avail_obj_dt)[, path := NULL]
Expand All @@ -70,15 +76,18 @@ listSubObjectMini = function(x = NULL) {
#' for the external version which provides those functions.
#' @keywords internal
list_subobject_mini = function() {

# declare data.table variables
path = type = NULL

miniobj_path = paste0(gDataDir(), '/Mini_objects/subobjects')

avail_obj = list.files(path = miniobj_path, full.names = TRUE, recursive = TRUE)
avail_obj_dt = data.table::data.table(file = basename(avail_obj), path = avail_obj)
avail_obj_dt[, type := gsub(pattern = paste0(miniobj_path, '/'), replacement = '', x = path)]
avail_obj_dt[, type := gsub(pattern = '[/].*', replacement = '', x = type)]
avail_obj_dt[, 'type' := gsub(pattern = paste0(miniobj_path, '/'), replacement = '', x = path)]
avail_obj_dt[, 'type' := gsub(pattern = '[/].*', replacement = '', x = type)]

avail_obj_dt[, index := seq_along(path), by = type]
avail_obj_dt[, 'index' := seq_along(path), by = type]

return(avail_obj_dt)

Expand Down
9 changes: 8 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ output: github_document
<!-- README.md is generated from README.Rmd. Please edit that file -->
<!-- This line is from RStudio -->

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/"
)
```

# GiottoData
# GiottoData <img src="man/figures/logo.png" align="right" alt="" width="160" />

Repo for GiottoData

Expand Down
Loading

0 comments on commit fa2ea87

Please sign in to comment.