{"id":13710922,"url":"https://github.com/willgearty/deeptime","last_synced_at":"2025-04-13T00:41:17.014Z","repository":{"id":41440546,"uuid":"152502088","full_name":"willgearty/deeptime","owner":"willgearty","description":"Plotting Tools for Anyone Working in Deep Time","archived":false,"fork":false,"pushed_at":"2024-10-25T13:48:05.000Z","size":99747,"stargazers_count":85,"open_issues_count":8,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-30T02:36:30.199Z","etag":null,"topics":["geology","ggplot2","paleontology","r","visualization"],"latest_commit_sha":null,"homepage":"https://williamgearty.com/deeptime/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willgearty.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-10T23:22:08.000Z","updated_at":"2024-10-26T22:37:38.000Z","dependencies_parsed_at":"2024-03-21T19:31:45.913Z","dependency_job_id":"7f472af4-6fd0-4c49-818b-e600f4075fb6","html_url":"https://github.com/willgearty/deeptime","commit_stats":{"total_commits":412,"total_committers":4,"mean_commits":103.0,"dds":0.007281553398058249,"last_synced_commit":"e9171467fb115eafe8b8309d0afc43f449a2f4e0"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willgearty%2Fdeeptime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willgearty%2Fdeeptime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willgearty%2Fdeeptime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willgearty%2Fdeeptime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willgearty","download_url":"https://codeload.github.com/willgearty/deeptime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650414,"owners_count":21139672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geology","ggplot2","paleontology","r","visualization"],"created_at":"2024-08-02T23:01:02.240Z","updated_at":"2025-04-13T00:41:16.982Z","avatar_url":"https://github.com/willgearty.png","language":"R","funding_links":[],"categories":["Plot layers"],"sub_categories":[],"readme":"# deeptime \u003cimg src=\"man/figures/logo.png\" align=\"right\" alt=\"\" width=\"120\"\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/willgearty/deeptime/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/willgearty/deeptime/actions/workflows/R-CMD-check.yaml)\n[![codecov](https://codecov.io/gh/willgearty/deeptime/branch/master/graph/badge.svg?token=VMT2EQQB8E)](https://app.codecov.io/gh/willgearty/deeptime)\n[![DOI](https://zenodo.org/badge/152502088.svg)](https://zenodo.org/badge/latestdoi/152502088)\n[![CRAN status](https://www.r-pkg.org/badges/version/deeptime)](https://CRAN.R-project.org/package=deeptime)\n[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/deeptime)](https://cran.r-project.org/package=deeptime)\n\u003c!-- badges: end --\u003e\n\n## Overview\n__deeptime__ extends the functionality of other plotting packages (notably\n`{ggplot2}`) to help facilitate the plotting of data over long time intervals,\nincluding, but not limited to, geological, evolutionary, and ecological data.\nThe primary goal of __deeptime__ is to enable users to add highly customizable\ntimescales to their visualizations. Other functions are also included to assist\nwith other areas of deep time visualization.\n\n## Installation\n```r\n# get the stable version from CRAN\ninstall.packages(\"deeptime\")\n\n# or get the development version from github\n# install.packages(\"devtools\")\ndevtools::install_github(\"willgearty/deeptime\")\n```\n\n## Usage\n\n### Load packages\n```r\nlibrary(deeptime)\nlibrary(ggplot2)\nlibrary(dplyr)\n```\n\n### Add one or more timescales to virtually any ggplot2 plot!\n\nThe main function of __deeptime__ is `coord_geo()`, which functions just like `coord_trans()` from `{ggplot2}`.\nYou can use this function to add highly customizable timescales to a wide variety of ggplots.\n\n```r\nlibrary(divDyn)\ndata(corals)\n\n# this is not a proper diversity curve but it gets the point across\ncoral_div \u003c- corals %\u003e% filter(stage != \"\") %\u003e%\n  group_by(stage) %\u003e%\n  summarise(n = n()) %\u003e%\n  mutate(stage_age = (stages$max_age[match(stage, stages$name)] +\n                        stages$min_age[match(stage, stages$name)])/2)\nggplot(coral_div) +\n  geom_line(aes(x = stage_age, y = n)) +\n  scale_x_reverse(\"Age (Ma)\") +\n  ylab(\"Coral Genera\") +\n  coord_geo(xlim = c(250, 0), ylim = c(0, 1700)) +\n  theme_classic(base_size = 16)\n```\n\n\u003cimg src=\"man/figures/example_bottom.png\"\u003e\n\n#### Lots of timescales available!\n\n```r\n# Load packages\nlibrary(gsloid)\n\n# Plot two different timescales\nggplot(lisiecki2005) +\n  geom_line(aes(x = d18O, y = Time / 1000), orientation = \"y\") +\n  scale_y_reverse(\"Time (Ma)\") +\n  scale_x_reverse(\"\\u03B418O\") +\n  coord_geo(\n    dat = list(\"Geomagnetic Polarity Chron\",\n               \"Planktic foraminiferal Primary Biozones\"),\n    xlim = c(6, 2), ylim = c(5.5, 0), pos = list(\"l\", \"r\"),\n    rot = 90, skip = \"PL4\", size = list(5, 4)\n  ) +\n  theme_classic(base_size = 16)\n```\n\n\u003cimg src=\"man/figures/example_left_right.png\"\u003e\n\n### Super flexible, supports multiple layouts, and works great with other packages!\n```r\n# Load packages\nlibrary(ggtree)\nlibrary(rphylopic)\n\n# Get vertebrate phylogeny\nlibrary(phytools)\ndata(vertebrate.tree)\n\nvertebrate.tree$tip.label[vertebrate.tree$tip.label ==\n                            \"Myotis_lucifugus\"] \u003c- \"Vespertilioninae\"\nvertebrate_data \u003c- data.frame(species = vertebrate.tree$tip.label,\n                              name = vertebrate.tree$tip.label)\n\n# Plot the phylogeny with a timescale\nrevts(ggtree(vertebrate.tree, size = 1)) %\u003c+%\n  vertebrate_data +\n  geom_phylopic(aes(name = name), size = 25) +\n  scale_x_continuous(\"Time (Ma)\", breaks = seq(-500, 0, 100),\n                     labels = seq(500, 0, -100), limits = c(-500, 0),\n                     expand = expansion(mult = 0)) +\n  scale_y_continuous(guide = NULL) +\n  coord_geo_radial(dat = \"periods\", end = 0.5 * pi) +\n  theme_classic(base_size = 16)\n```\n\n\u003cimg src=\"man/figures/example_phylogeny.png\"\u003e\n\n### Does lots of other things too!\n\n#### Plot fossil occurence ranges\n```r\nlibrary(palaeoverse)\n\n# Filter occurrences\noccdf \u003c- subset(tetrapods, accepted_rank == \"genus\")\noccdf \u003c- subset(occdf, accepted_name %in%\n                  c(\"Eryops\", \"Dimetrodon\", \"Diadectes\", \"Diictodon\",\n                    \"Ophiacodon\", \"Diplocaulus\", \"Benthosuchus\"))\n\n# Plot occurrences\nggplot(data = occdf) +\n  geom_points_range(aes(x = (max_ma + min_ma)/2, y = accepted_name)) +\n  scale_x_reverse(name = \"Time (Ma)\") +\n  ylab(NULL) +\n  coord_geo(pos = list(\"bottom\", \"bottom\"), dat = list(\"stages\", \"periods\"),\n            abbrv = list(TRUE, FALSE), expand = TRUE, size = \"auto\") +\n  theme_classic(base_size = 16)\n```\n\n\u003cimg src=\"man/figures/example_points_range.png\"\u003e\n\n#### Use standardized geological patterns\n\n```r\n# Load packages\nlibrary(rmacrostrat)\nlibrary(ggrepel)\n\n# Retrieve the Macrostrat units in the San Juan Basin column\nsan_juan_units \u003c- get_units(column_id = 489, interval_name = \"Cretaceous\")\n\n# Specify x_min and x_max in dataframe\nsan_juan_units$x_min \u003c- 0\nsan_juan_units$x_max \u003c- 1\n# Tweak values for overlapping units\nsan_juan_units$x_max[10] \u003c- 0.5\nsan_juan_units$x_min[11] \u003c- 0.5\n\n# Add midpoint age for plotting\nsan_juan_units$m_age \u003c- (san_juan_units$b_age + san_juan_units$t_age) / 2\n\n# Get lithology definitions\nliths \u003c- def_lithologies()\n\n# Get the primary lithology for each unit\nsan_juan_units$lith_prim \u003c- sapply(san_juan_units$lith, function(df) {\n  df$name[which.max(df$prop)]\n})\n\n# Get the pattern codes for those lithologies\nsan_juan_units$pattern \u003c- factor(liths$fill[match(san_juan_units$lith_prim, liths$name)])\n\n# Plot with pattern fills\nggplot(san_juan_units, aes(ymin = b_age, ymax = t_age,\n                           xmin = x_min, xmax = x_max)) +\n  # Plot units, patterned by rock type\n  geom_rect(aes(fill = pattern), color = \"black\") +\n  scale_fill_geopattern() +\n  # Add text labels\n  geom_text_repel(aes(x = x_max, y = m_age, label = unit_name),\n                  size = 3.5, hjust = 0, force = 2,\n                  min.segment.length = 0, direction = \"y\",\n                  nudge_x = rep_len(x = c(2, 3), length.out = 17)) +\n  # Reverse direction of y-axis\n  scale_y_reverse(limits = c(145, 66), n.breaks = 10, name = \"Time (Ma)\") +\n  # Theming\n  theme_classic(base_size = 16) +\n  theme(legend.position = \"none\",\n        axis.line.x = element_blank(),\n        axis.title.x = element_blank(),\n        axis.text.x = element_blank(),\n        axis.ticks.x = element_blank()) +\n  # Add geological time scale\n  coord_geo(pos = \"left\", dat = list(\"stages\"), rot = 90)\n```\n\n\u003cimg src=\"man/figures/example_patterns.png\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillgearty%2Fdeeptime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillgearty%2Fdeeptime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillgearty%2Fdeeptime/lists"}