{"id":19434595,"url":"https://github.com/edawson/tidysig","last_synced_at":"2025-08-12T18:18:07.575Z","repository":{"id":150736416,"uuid":"243092054","full_name":"edawson/tidysig","owner":"edawson","description":"A tidyverse-style package for plotting mutational signatures and context counts.","archived":false,"fork":false,"pushed_at":"2021-02-12T22:37:50.000Z","size":517,"stargazers_count":4,"open_issues_count":9,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-25T06:29:46.112Z","etag":null,"topics":["cancer-genomics","ggplot2","mutational-signatures","tidy-data","tidyverse"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edawson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-02-25T20:08:17.000Z","updated_at":"2025-02-06T21:18:01.000Z","dependencies_parsed_at":"2023-04-12T13:23:14.942Z","dependency_job_id":null,"html_url":"https://github.com/edawson/tidysig","commit_stats":{"total_commits":111,"total_committers":1,"mean_commits":111.0,"dds":0.0,"last_synced_commit":"15d02819f64779b31db986875728b60fd3b3946c"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/edawson/tidysig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edawson%2Ftidysig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edawson%2Ftidysig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edawson%2Ftidysig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edawson%2Ftidysig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edawson","download_url":"https://codeload.github.com/edawson/tidysig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edawson%2Ftidysig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270111043,"owners_count":24529199,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cancer-genomics","ggplot2","mutational-signatures","tidy-data","tidyverse"],"created_at":"2024-11-10T14:46:57.244Z","updated_at":"2025-08-12T18:18:06.897Z","avatar_url":"https://github.com/edawson.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"tidysig\n--------\nEric T. Dawson  \nFebruary 2020\n\n\n![R-CMD-check](https://github.com/edawson/tidysig/workflows/R-CMD-check/badge.svg)\n\n## Introduction\ntidysig is an R package for plotting mutational\nsignatures / mutational contexts in\nthe tidyverse style.\nIt produces ggplot2 plots of SBS96\nand ID83 features which can then\nbe modified with standard ggplot2 layers. It attempts to make\nplotting signatures simpler by requiring strict\nformatting and abstracting as much as possible.\n\n## Installation\n\ntidysig can be installed with devtools:  \n```\nlibrary(devtools)\ndevtools::install_github(\"edawson/tidysig\")\n```\n\nTo build from the GitHub source:\n```\ngit clone --recursive https://github.com/edawson/tidysig\ncd tidysig\nRscript scripts/devtools_install.R\n```\n\nIf you want compatibility with SignatureAnalyzer, you'll need to install HDF5.\nIf you've installed SignatureAnalyzer locally, this is already on your computer.\nOtherwise, you can install is for linux:\n```\nsudo apt-get install libhdf5-serial-dev\n```\n\nOr Mac OS X:\n```\n brew install hdf5\n``` \n\nThe required R packages are listed in DESCRIPTION. Most are standard TidyVerse packages\n(plus cowplot). In addition, [hdf5r](https://cran.r-project.org/web/packages/hdf5r/index.html)\nis needed for SigantureAnalyzer files.\n\n## Compatibility\ntidysig is currently compatible with SigProfilerExtractor (as of version 1.0.3),\nwith plans to support SignatureAnalyzer.\n\n**Nota bene:** There is a known incompatibility with some SigProfilerExtractor outputs,\nwhich have a first column titled \"MutationsType\" instead of \"MutationType.\" This can be remedied with the following dplyr::rename call after reading in the file:\n```\nsigprofiler_results \u003c- read_tsv(\"sigprofiler_results/SBS96/Suggested_Solution/De_Novo_Solution/De_Novo_Solution_Signatures_SBS96.txt\")\n\n\nsigprofiler_results \u003c- sigprofiler_results %\u003e%\n  rename(MutationType=MutationsType)\n```\n\n## Tidy signature representation\nInternally, tidysig converts SigProfiler outputs to a tidy data format with four variables for SBS96\nsignatures and six variables for ID83 signatures.\n\n*SBS96 Columns:*\n| *Column Name* | Signature | Change | Context | Amount |\n|---------------|-------------------------------------|---------------------------------------|:-----------------------------------------:|--------------------------------------------------------|\n| *Description* | The name of the signature or sample | The genomic change (i.e., T\u003eN or C\u003eN) | The trinucleotide context of the variant. | The amount, either as a raw counts or as a proportion. |\n\n\n*ID83 Features*  \n| *Column Name* | Signature | Type | Length | Motif | Motif Length | Amount |\n|---------------|-------------------------------------|------------------------------------|:---------------------------------------:|------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|--------------------------------------------------------|\n| *Description* | The name of the signature or sample | INS or DEL (insertion or deletion) | The length of the insertion or deletion | The motif surrounding the variant (i.e., within a C/T homopolymer, within a repeat, within microhomology)  | The length of the motif (in basepairs or repeat units) | The amount, either as a raw counts or as a proportion. |\n## Usage\n\nLoad a SigProfilerExtractor file as input and plot all signatures:  \n```R\nlibrary(tidysig)\nlibrary(readr)\n\nsigprofiler_results \u003c- read_tsv(\"sigprofiler_results/SBS96/Suggested_Solution/De_Novo_Solution/De_Novo_Solution_Signatures_SBS96.txt\")\n\ndf \u003c- transform_sigprofiler_df(sigprofiler_results)\n\nall_sig_plot \u003c- plot_SBS96_signature(df)\n```\n\u003cobject data=\"https://github.com/edawson/tidysig/blob/master/images/sbs96_example_plot.pdf\" type=\"application/pdf\" width=\"700px\" height=\"700px\"\u003e\n    \u003cembed src=\"https://github.com/edawson/tidysig/blob/master/images/sbs96_example_plot.pdf\"\u003e\n        \u003cp\u003ePlease download the PDF to view SBS96 plot: \u003ca href=\"https://github.com/edawson/tidysig/blob/master/images/sbs96_example_plot.pdf\"\u003eDownload PDF\u003c/a\u003e.\u003c/p\u003e\n    \u003c/embed\u003e\n\u003c/object\u003e\n\n\nIn addition, the resulting plots can be modified:\n\n```R\n## Counts can be normalized to proportions using the countsAsProportions argument\nall_sig_plot_proportions \u003c- plot_SBS96_signature(df, countsAsProportions=TRUE)\n\n## You can apply the same y-axis limits to all subplots to make comparison between signatures easier.\nall_sig_plot_proportions_norm \u003c- plot_sbs96_signature(df, countsAsProportions=TRUE, ylimits=c(0,0.5)\n\n## To plot a specific signature, you can filter using standard dplyr commands.\nsig_96A_plot \u003c- plot_SBS96_signature(df %\u003e% dplyr::filter(Signature == \"96A\"))\n\n## Or, use the %in% operator for multiple signatures:\nsig_96A_96B_plot \u003c- plot_SBS96_signature(df %\u003e% dplyr::filter(Signature %in% c(\"96A\", \"96B\")))\n\n## Plots can be saved using cowplot/ggplot2's save_plot function.\nsave_plot(\"all_sigs.pdf\", all_sig_plot ,base_height = 6, base_asp=2)\n\n## For single signatures, you can use the save_signature_plot function\nsave_signature_plot(sig_96A_plot, \"sig_96A_plot.pdf\")\n```\n\nYou can layer on standard ggplot2 layers. Here's an example\nwhere we remove sample names and change the theme to theme\\_bw():\n```R\nactiv \u003c- transform_sigprofiler_df(\n    read_tsv(\"sigprofiler_results/SBS96/Suggested_Solution/De_Novo_Solution/De_Novo_Solution_Activities_SBS96.txt\")\n)\n\nplot_signature_activities(activ %\u003e%\n       group_by(Sample) %\u003e%\n       mutate(high = ifelse(sum(Amount) \u003e 1000, \"High\", \"Low\")),\n    countsAsProportions = F,\n    showSampleNames = T,\n    facetGroupVariable = \"high\") +\ntheme(axis.text.x = element_blank()) +\ntheme_bw()\n```\n\n## Prerequisites\nYou'll need to run SigProfiler to generate the inputs for tidysig.\nSigProfiler can be installed with PIP. Note, I've frozen on specific\nversions - check pip for the latest ones if you want to try them.\n\n```bash\n## if on a compute cluster, run:\n## module load python\n\n## Install SigProfiler to user directory using pip:\npip install --user SigProfilerExtractor==1.0.3\n\n## Install SigProfilerMatrixGenerator:\npip install --user SigProfilerMatrixGenerator==1.1.0\n```\n\nThe SigProfilerHelper utilities can be used to run SigProfiler from the command\nline, rather than running it in a python REPL:\n```bash\ngit clone https://github.com/edawson/SigProfilerHelper sigprofilerhelper\n```\n\nYou need to first install a reference genome, such as GRCh37 (hg19):\n```bash\npython sigprofilerhelper/install_reference.py -g GRCh37\n```\n\nYou can then generate a mutational counts file:\n```bash\npython sigprofilerhelper/generate_matrix -m \u003cmaf_file\u003e\n```\n\nThis will produce a directory (default name: sigprof\\_input) which contains \nthe inputs for SigProfilerExtractor. Another helper script can take this as\ninput and produce mutational signatures:\n```bash\n## Run SigProfilerExtractor for an SBS96 counts matrix,\n## for 1 to 7 signatures,\n## using 16 cores and 1000 iterations\npython sigprofilerhelper/run_sigrofiler.py -t sigprof_input/output/SBS/PROJECT.SBS96.all -s 1 -e 7 -i 1000 -c 16\n```\n\nIf you're on Biowulf (or another cluster using SLURM, you can write the following wrapper script:\n```bash\n#!/bin/bash\nmodule load python\n\npython sigprofilerhelper/run_sigrofiler.py -t sigprof_input/output/SBS/PROJECT.SBS96.all -s 1 -e 7 -i 1000 -c ${SLURM_CPUS_PER_TASK}\n```\n\nSave this file (as an example, to \"run\\_sigpro.sh\")\nand submit it to a queue like so:\n```bash\nsbatch --cpus-per-task=16 --mem=20g --error=sigpro.err.txt --ouput=sigpro.out.txt run_sigpro.sh\n```\n\nIn a few hours (usually 3-5), you'll get output in a directory called sigpro\\_results, which\nwill contain the inputs for tidysig.\n\n## Citing the R package\nYou are free to use tidysig under the broadly-permissive MIT license. We ask \nthat you cite it in the following manner:\n```\ntidysig: a tidyverse-style package for plotting mutational signatures. https://github.com/edawson/tidysig, Version \u003cVERSION\u003e. Eric T. Dawson. 2020.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedawson%2Ftidysig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedawson%2Ftidysig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedawson%2Ftidysig/lists"}