Scripts N Snippets

Scripts N Snippets

💎 Repo with scripts and snippets that help me organize my Obsidian vault.

💎 obsidian-scripts-n-snippets

This repo is a library of scripts and code snippets that help me organize my Obsidian vault better, faster, and cleaner.

Obsidian

🤖 Automated Creation of Notes

🧬 Marker Genes

Briefly: R script that transforms a TSV/CSV file into markdown notes with YAML metadata for automated integration into Obsidian. The script is dedicated to the creation of notes on marker genes -one note per gene- following a pre-selected note template. The input file follows a specific table format that (currently) works best for the organization of marker genes. The created markdown is outputed directly inside the Obsidian vault. See below for more details on the input format and markdown note structure.

Input File

The R script assumes specific YAML metadata entries and, by extension, specific columns in the input file. Following the note template that is currently used in my Obsidian vault, an example for a gene entry in the input file is shown below:

namealiasesmm-genehs-genecommon-namecelltypesubtypesourcenotestumormain-bodyupdate
Mki67KI-67, Ki-67Mki67MonocytesProliferatingMolgora (2020)[[Molgora-Cell-2020]]TRUE
Mki67KI-67, Ki-67Mki67MacrophagesProliferatingMolgora (2020)[[Molgora-Cell-2020]]TRUE
Mki67KI-67, Ki-67Mki67NeutrophilsNeutrophilsPanglaoDBTRUE
Details on the metadata entries:
Input file columnDetails
namename of Obsidian note
aliasesalternative names to facilitate connections between Obsidian notes
mm-geneMus musculus gene name
hs-geneHomo sapiens gene name
common-nameother, commonly used gene names
celltypecell type classification
subtypecell type sub-type classification
sourcemarkdown-format link leading to the publication or source that reported the celltype and subtype classification
notesObsidian link to related Obsidian note, e.g. link to the notes on corresponding paper
tumorrelated tumor type
main-bodytext to be written in the note's main body
updatebinary, whether to update the note inside the obsidian vault; if TRUE, existing note will be overwritten

Entries with the same name are collapsed under the same note. If there are multiple entries for the same note, if there is any entry with update = TRUE, then the note will be updated.

Output Note Structure

The marker note template follows the following structure for its metadata entries/ header:

---
aliases: []
mm-gene:
hs-gene:
common-name:
celltype:
celltype-subtype-source-notes: 
- ";[](https://doi.org/)"
tumor:
---

Links: [[000 Vault TOC]], [[030 Gene Cards]]
#marker

---

The Links are Obsidian links to upper-level MOC notes (used when the Obsidian vault follows the Map of Contents structure, nice link here).

Running the Script

The script takes two arguments, the path to the input TSV/CSV file, and the output directory (or sub-directory inside the Obsidian vault).

Rscript Obsidian.Table_to_Marker_Note.R --INPUTFILE "ImmuneMarkersLeda.tsv"
                                        --OUTPUTDIR "/home/leda/ObsidianVault/030\ Gene\ Cards"

🥐 Code Snippets

📑 Dataview Queries

1. Dataview query for organizing gene markers into columns based on the celltype/sub-type classification and the respective source

```dataview
TABLE WITHOUT ID
	split(string(celltype-subtype-source-notes), ";")[1] AS Sub-type,
	rows.file.link AS Markers,
	split(string(celltype-subtype-source-notes), ";")[2] AS Source,
	split(string(celltype-subtype-source-notes), ";")[3] AS Notes
FROM #marker
FLATTEN celltype-subtype-source-notes
WHERE split(string(celltype-subtype-source-notes), ";")[0] = "Macrophages"
GROUP BY celltype-subtype-source-notes
SORT celltype-subtype-source-notes ASC

2. Dataview query for organizing notes on papers

```dataview
table without ID
	file.link as Paper, Title, Tags
from "050 Papers"
where length(Title) > 0
sort DateRead desc

🍨 Templates

🐚 Obsidian x Zotero Integration

This template, as found here, contains the formatting options and code to import paper metadata and PDF annotation from Zotero. It is used by the Obsidian Zotero Integration Obsidian plugin as the default template to create new notes and import the specified metadata and notes.

Obsidian plugin requirements:

Zotero plugin requirements:

  • Better BibTex for Zotero - for proper citation handling, citation key creation to be used for automated note naming, easier metadata handling

The template was inspired by and adjusted from the following posts:

Related

How to Install

  1. Download the template file from GitHub
  2. Move it anywhere in your vault
  3. Open it in Obsidian — done!

Stats

Stars

3

Forks

0

License

MIT

Last updated 39mo ago

Categories

Tags

obsidian