Skip to content

Commit

Permalink
version 0.0.9.9100
Browse files Browse the repository at this point in the history
tidying up for next release
  • Loading branch information
ramiromagno committed Jul 4, 2024
1 parent 277b3fe commit d442811
Show file tree
Hide file tree
Showing 28 changed files with 280 additions and 106 deletions.
4 changes: 3 additions & 1 deletion .github/SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Getting help

Thank you for using `{mgi.report.reader}`!

- If you have a GitHub account, please
[file an issue](https://github.com/patterninstitute/mgi.report.reader/issues/new)
with your question or bug report.

- If you do not have a GitHub account, you can contact the maintainer of this
- If you do not have a GitHub account, you can contact Ramiro Magno, the maintainer of this
package at <[email protected]>.

- If your question pertains more directly to data obtained from the Mouse Genomics Informatics (MGI),
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mgi.report.reader
Title: Read Mouse Genome Informatics Reports
Version: 0.0.9.9000
Version: 0.0.9.9100
Authors@R: c(
person("Ramiro", "Magno", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5226-3441")),
Expand Down
6 changes: 4 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Generated by roxygen2: do not edit by hand

export(chromosomes)
export(open_in_mgi)
export(feature_types)
export(marker_types)
export(open_marker_in_mgi)
export(read_report)
export(report_datetime)
export(report_file)
export(report_last_modified)
export(report_name)
export(report_source)
export(report_type)
Expand Down
10 changes: 5 additions & 5 deletions R/browser.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mgi_reports_index_md <- function() {

#' Browse MGI markers online
#'
#' [open_in_mgi()] launches the web browser and opens a tab for each MGI
#' [open_marker_in_mgi()] launches the web browser and opens a tab for each MGI
#' accession identifier on the Mouse Genome Informatics web interface:
#' \url{https://www.informatics.jax.org}.
#'
Expand All @@ -48,14 +48,14 @@ mgi_reports_index_md <- function() {
#'
#' @examples
#' # Read about Acta1 (actin alpha 1, skeletal muscle) online.
#' open_in_mgi("MGI:87902")
#' open_marker_in_mgi("MGI:87902")
#'
#' # `open_in_mgi()` is vectorized, so you can open multiple pages.
#' # `open_marker_in_mgi()` is vectorized, so you can open multiple pages.
#' # NB: think twice if you really need to open many tabs at once.
#' open_in_mgi(c("MGI:87902", "MGI:87909"))
#' open_marker_in_mgi(c("MGI:87902", "MGI:87909"))
#'
#' @export
open_in_mgi <- function(marker_id) {
open_marker_in_mgi <- function(marker_id) {
if (!(all(is_mgi_identifier(marker_id))))
stop("`marker_id` must be a character vector of valid MGI identifiers.")

Expand Down
26 changes: 21 additions & 5 deletions R/data.R → R/feature_types.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
#' Genome Feature Types
#' Genome Feature Type Definitions
#'
#' A dataset containing different types of gene and genome features along with
#' their Sequence Ontology (SO) identifiers and definitions.
#'
#' @format A [tibble][tibble::tibble-package] with `r nrow(feature_types)` rows
#' and `r ncol(feature_types)` variables:
#' @format A [tibble][tibble::tibble-package] with `r nrow(feature_type_definitions)` rows
#' and `r ncol(feature_type_definitions)` variables:
#' \describe{
#' \item{feature_type}{Character. The type of gene or genome feature.}
#' \item{so_id}{Character. The Sequence Ontology identifier associated with the feature type.}
#' \item{definition}{Character. The definition of the feature type.}
#' }
#'
#' @examples
#' print(feature_types, n = Inf)
#' print(feature_type_definitions, n = Inf)
#'
#' @source
#' The table in \url{https://www.informatics.jax.org/userhelp/GENE_feature_types_help.shtml}
#' and a few other terms found in MGI reports.
"feature_types"
"feature_type_definitions"


#' Genome Feature types
#'
#' [feature_types()] returns different types of gene and genome features. For
#' feature type definitions, see `?feature_type_definitions`.
#'
#' @returns A character vector of feature types' names.
#'
#' @examples
#' feature_types()
#'
#' @export
feature_types <- function() {
feature_type_definitions$feature_type
}
10 changes: 10 additions & 0 deletions R/marker_types.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#' Genetic marker types
#'
#' [marker_types()] returns MGI marker types.
#'
#' @returns A character vector.
#'
#' @examples
#' marker_types()
#'
#' @export
marker_types <- function() {
c(
"Gene",
Expand Down
2 changes: 1 addition & 1 deletion R/read_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ read_report <- function(report_key = NULL,
rpt_last_modified <- find_report_last_modified(report_file)

attr(tbl, "report_source") <- rpt_source
attr(tbl, "report_datetime") <- rpt_last_modified
attr(tbl, "report_last_modified") <- rpt_last_modified

tbl
}
Expand Down
32 changes: 16 additions & 16 deletions R/report_column_processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
# factor(marker_type, levels = marker_types())
# }

protein_ids_col <- function(protein_ids) {

protein_ids <- strsplit(protein_ids, " ", fixed = TRUE)
# Convert single NA values to empty character vectors in the list-column.
dplyr::if_else(sapply(protein_ids, \(x) length(x) == 1L && is.na(x)), list(character()), protein_ids)
}
# protein_ids_col <- function(protein_ids) {
#
# protein_ids <- strsplit(protein_ids, " ", fixed = TRUE)
# # Convert single NA values to empty character vectors in the list-column.
# dplyr::if_else(sapply(protein_ids, \(x) length(x) == 1L && is.na(x)), list(character()), protein_ids)
# }

# cell_line_col <- function(cell_line) {
#
Expand All @@ -51,16 +51,16 @@ protein_ids_col <- function(protein_ids) {
# dplyr::if_else(sapply(cell_line, \(x) length(x) == 1L && is.na(x)), list(character()), cell_line)
# }

special_feature_type_col <- function(feature_type) {

# In cases like:
# "lncRNA gene|lncRNA gene|lncRNA gene"
# keep only one instance. This assumes the values pipe-separated are repeated,
# this is the case in MRK_ENSEMBL.rpt.
feature_type <- sub("\\|.+", "", feature_type)

factor(feature_type, levels = feature_types$feature_type)
}
# special_feature_type_col <- function(feature_type) {
#
# # In cases like:
# # "lncRNA gene|lncRNA gene|lncRNA gene"
# # keep only one instance. This assumes the values pipe-separated are repeated,
# # this is the case in MRK_ENSEMBL.rpt.
# feature_type <- sub("\\|.+", "", feature_type)
#
# factor(feature_type, levels = feature_types$feature_type)
# }

# biotype_col <- function(biotype) {
# biotype <- strsplit(biotype, "|", fixed = TRUE)
Expand Down
22 changes: 17 additions & 5 deletions R/report_source.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,25 @@ find_report_last_modified <- function(file) {
NA_character_
}

#' Report datetime
#' Report last modification date
#'
#' [report_datetime()] the last modified date and time of the report source
#' (local file or remote file).
#' [report_last_modified()] returns the last modified date and time of the
#' report source (local file or remote file).
#'
#' @param tbl Report data as a [tibble][tibble::tibble-package].
#'
#' @returns A last modified date-time as a [POSIXct][base::DateTimeClasses]
#' object.
#'
#' @examples
#' markers <- read_report("marker_list1", n_max = 10L)
#'
#' # When was the report file last updated?
#' report_last_modified(markers)
#'
#' @export
report_datetime <- function(tbl) {
attr(tbl, "report_datetime")
report_last_modified <- function(tbl) {
attr(tbl, "report_last_modified")
}


Expand All @@ -65,6 +71,12 @@ report_datetime <- function(tbl) {
#'
#' @returns A single string with an absolute path to a file on disk or an URL.
#'
#' @examples
#' markers <- read_report("marker_list1", n_max = 10L)
#'
#' # Where did the data come from?
#' report_source(markers)
#'
#' @export
report_source <- function(tbl) {
attr(tbl, "report_source")
Expand Down
4 changes: 2 additions & 2 deletions R/reports.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ get_reports_col <- function(report_key, col) {
dplyr::pull(col)
}

#' Get report attributes by report key
#' Get MGI report specs by report key
#'
#' Set of functions to retrieve attributes of a MGI report.
#' Set of functions to retrieve metadata details of a MGI report.
#'
#' @inheritParams common-args
#'
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion R/variable_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ col_strand <- function(x) {
}

col_feature_type <- function(x) {
factor(x, levels = feature_types$feature_type) |>
factor(x, levels = feature_types()) |>
add_label_to_feature_type()
}

Expand Down
29 changes: 19 additions & 10 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ template:

navbar:
structure:
left: [intro, articles, reference, news]
left: [intro, concepts, articles, reference, news]
right: [search, github]
components:
concepts:
text: Concepts
menu:
- text: Genetic Marker
href: articles/genetic_marker.html
articles:
text: Reports
menu:
Expand Down Expand Up @@ -45,20 +50,24 @@ navbar:
reference:
- title: MGI Reports

- subtitle: Reading Reports
contents:
- read_report
- report_source
- report_last_modified
- report-attributes

- subtitle: Data
contents:
- reports
- feature_types
- feature_type_definitions

- subtitle: Reading
- subtitle: Enumerations
contents:
- read_report
- report_source
- report_datetime
- chromosomes
- marker_types
- feature_types

- subtitle: Helpers
contents:
- open_in_mgi
- chromosomes
- report-attributes

- open_marker_in_mgi
8 changes: 4 additions & 4 deletions data-raw/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ order <-
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71
)

feature_types <- feature_types01[order, ]
feature_type_definitions <- feature_types01[order, ]

# Export to file too.
readr::write_csv(feature_types, file = "data-raw/feature_types.csv")
readr::write_csv(feature_type_definitions, file = "data-raw/feature_type_definitions.csv")
readr::write_csv(reports, file = "data-raw/reports.csv")

# Export data sets
usethis::use_data(feature_types, overwrite = TRUE, compress = "xz")
usethis::use_data(feature_type_definitions, overwrite = TRUE, compress = "xz")
usethis::use_data(reports, overwrite = TRUE, compress = "xz")

# Internal data
usethis::use_data(reports, feature_types, internal = TRUE, overwrite = TRUE)
usethis::use_data(reports, feature_type_definitions, internal = TRUE, overwrite = TRUE)
File renamed without changes.
Binary file added data/feature_type_definitions.rda
Binary file not shown.
Binary file removed data/feature_types.rda
Binary file not shown.
31 changes: 31 additions & 0 deletions man/feature_type_definitions.Rd

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

30 changes: 9 additions & 21 deletions man/feature_types.Rd

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

Loading

0 comments on commit d442811

Please sign in to comment.