1010# ' @param simplify A logical indicating whether to simplify the resulting data frame
1111# ' by removing list columns. Default is TRUE.
1212# '
13- # ' @returns a data frame of project information from the ScPCA API.
13+ # ' @returns a data frame (tibble) of project information from the ScPCA API.
1414# '
1515# ' @import httr2
1616# ' @importFrom dplyr .data
@@ -47,17 +47,22 @@ scpca_projects <- function(simplify = TRUE) {
4747 created_at = as.POSIXct(.data $ created_at ),
4848 updated_at = as.POSIXct(.data $ updated_at )
4949 ) | >
50- dplyr :: relocate(scpca_project_id = " scpca_id" )
50+ dplyr :: relocate(
51+ scpca_project_id = " scpca_id" ,
52+ " sample_count" ,
53+ " title" ,
54+ " pi_name"
55+ )
5156
52- project_df
57+ tibble :: as_tibble( project_df )
5358}
5459
5560# ' Get project metadata by project ID
5661# '
5762# ' @param project_id The ScPCA project ID (e.g. "SCPCP000001")
5863# ' @param simplifyVector Simplify the returned list structure,
5964# ' creating vectors and data frames instead of lists when possible.
60- # ' Default is FALSE .
65+ # ' Default is TRUE .
6166# '
6267# ' @returns A nested list of project metadata from the ScPCA API.
6368# '
@@ -69,7 +74,7 @@ scpca_projects <- function(simplify = TRUE) {
6974# ' # Get metadata for a specific project
7075# ' project_info <- get_project_info("SCPCP000001")
7176# ' }
72- get_project_info <- function (project_id , simplifyVector = FALSE ) {
77+ get_project_info <- function (project_id , simplifyVector = TRUE ) {
7378 stopifnot(
7479 " Invalid project_id." = grepl(" ^SCPCP\\ d{6}$" , project_id )
7580 )
@@ -102,7 +107,7 @@ get_project_info <- function(project_id, simplifyVector = FALSE) {
102107# ' @param simplify A logical indicating whether to simplify the resulting data frame
103108# ' by removing list columns. Default is TRUE.
104109# '
105- # ' @returns A data frame of sample information for the specified project from the ScPCA API.
110+ # ' @returns A data frame (tibble) of sample information for the specified project from the ScPCA API.
106111# '
107112# ' @import httr2
108113# ' @importFrom dplyr .data
@@ -137,9 +142,12 @@ get_project_samples <- function(project_id, simplify = TRUE) {
137142 created_at = as.POSIXct(.data $ created_at ),
138143 updated_at = as.POSIXct(.data $ updated_at )
139144 ) | >
140- dplyr :: relocate(scpca_sample_id = " scpca_id" , scpca_project_id = " project" )
145+ dplyr :: relocate(
146+ scpca_sample_id = " scpca_id" ,
147+ scpca_project_id = " project"
148+ )
141149
142- sample_df
150+ tibble :: as_tibble( sample_df )
143151}
144152
145153
@@ -200,7 +208,7 @@ get_project_libraries <- function(project_id, auth_token) {
200208 is_cols <- stringr :: str_subset(colnames(library_metadata ), " ^(is|has|includes)_" )
201209 library_metadata <- library_metadata | >
202210 dplyr :: mutate(dplyr :: across(dplyr :: all_of(is_cols ), as.logical ))
203- library_metadata
211+ tibble :: as_tibble( library_metadata )
204212}
205213
206214
0 commit comments