<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Pharmacology | Ville Langén</title><link>https://villelangen.com/tags/pharmacology/</link><atom:link href="https://villelangen.com/tags/pharmacology/index.xml" rel="self" type="application/rss+xml"/><description>Pharmacology</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Sun, 01 Dec 2024 00:00:00 +0000</lastBuildDate><image><url>https://villelangen.com/media/icon_hu7353780716416406245.png</url><title>Pharmacology</title><link>https://villelangen.com/tags/pharmacology/</link></image><item><title>atctools: R Package for ATC Code Matching and Validation</title><link>https://villelangen.com/dev-work/atctools/</link><pubDate>Sun, 01 Dec 2024 00:00:00 +0000</pubDate><guid>https://villelangen.com/dev-work/atctools/</guid><description>&lt;p>&lt;strong>atctools&lt;/strong> is an R package created by Ville Langén that facilitates Anatomical Therapeutic Chemical (ATC) matching and ensures the integrity of ATC data in pharmaceutical datasets. This specialized tool is essential for pharmaceutical research, drug safety studies, and healthcare data analysis.&lt;/p>
&lt;h2 id="overview">Overview&lt;/h2>
&lt;p>The atctools package provides comprehensive tools for working with ATC codes, which are used worldwide to classify drugs according to the organ or system on which they act and their therapeutic, pharmacological, and chemical properties. The package bridges the gap between drug names and their standardized ATC classifications.&lt;/p>
&lt;h2 id="key-features">Key Features&lt;/h2>
&lt;h3 id="-atc-matching-functions">🔍 &lt;strong>ATC Matching Functions&lt;/strong>&lt;/h3>
&lt;p>&lt;strong>Advanced drug name matching&lt;/strong> using sophisticated algorithms including Levenshtein distance for fuzzy matching, ensuring accurate identification even with spelling variations or formatting differences.&lt;/p>
&lt;h3 id="-atc-code-matching">🏷️ &lt;strong>ATC Code Matching&lt;/strong>&lt;/h3>
&lt;p>&lt;strong>Direct ATC-to-drug name matching&lt;/strong> for reverse lookups and data verification workflows.&lt;/p>
&lt;h3 id="-atc-data-integrity-checks">✅ &lt;strong>ATC Data Integrity Checks&lt;/strong>&lt;/h3>
&lt;p>&lt;strong>Comprehensive validation tools&lt;/strong> to verify the structure and validity of ATC codes using authoritative reference lists.&lt;/p>
&lt;h2 id="core-functions">Core Functions&lt;/h2>
&lt;h3 id="drug_match">drug_match()&lt;/h3>
&lt;p>Matches drug names to ATC codes &lt;strong>without stripping&lt;/strong> trailing characters like &amp;ldquo;mg&amp;rdquo;, &amp;ldquo;g&amp;rdquo;, etc.&lt;/p>
&lt;p>&lt;strong>Usage:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-r" data-lang="r">&lt;span class="line">&lt;span class="cl">&lt;span class="nf">library&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">atctools&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">output_data&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">drug_match&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">example_drug_data&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s">&amp;#34;drug_name&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">example_reference_data&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">output_data&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Key Features:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Preserves original drug name formatting&lt;/li>
&lt;li>Uses fuzzy matching algorithms for robust identification&lt;/li>
&lt;li>Includes confidence scoring through &lt;code>drug_name_flag&lt;/code>&lt;/li>
&lt;/ul>
&lt;h3 id="drug_match_strip">drug_match_strip()&lt;/h3>
&lt;p>Matches drug names to ATC codes &lt;strong>with trailing characters stripped&lt;/strong> for cleaner matching.&lt;/p>
&lt;p>&lt;strong>Usage:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-r" data-lang="r">&lt;span class="line">&lt;span class="cl">&lt;span class="n">output_data_stripped&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">drug_match_strip&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">example_drug_data_with_mg&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s">&amp;#34;drug_name&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">example_reference_data&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">output_data_stripped&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Perfect for:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Drug names with dosage information (e.g., &amp;ldquo;paracetamol 500mg&amp;rdquo;)&lt;/li>
&lt;li>Standardizing drug nomenclature&lt;/li>
&lt;li>Handling varied formatting in clinical datasets&lt;/li>
&lt;/ul>
&lt;h3 id="atc2drug">atc2drug()&lt;/h3>
&lt;p>Matches ATC codes back to drug names directly with &lt;strong>no fuzzy matching&lt;/strong> for precise lookups.&lt;/p>
&lt;p>&lt;strong>Usage:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-r" data-lang="r">&lt;span class="line">&lt;span class="cl">&lt;span class="n">output_data_atc2drug&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">atc2drug&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">example_atc_data&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s">&amp;#34;ATC_code&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">example_reference_data&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">output_data_atc2drug&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Use Cases:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Reverse lookups from ATC to drug names&lt;/li>
&lt;li>Data verification and validation&lt;/li>
&lt;li>Creating drug dictionaries from ATC classifications&lt;/li>
&lt;/ul>
&lt;h2 id="-atc-validation-functions">🔍 ATC Validation Functions&lt;/h2>
&lt;h3 id="validate_atc">validate_atc()&lt;/h3>
&lt;p>Checks if ATC codes follow the &lt;strong>correct structural format&lt;/strong> (length, character pattern).&lt;/p>
&lt;p>&lt;strong>Usage:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-r" data-lang="r">&lt;span class="line">&lt;span class="cl">&lt;span class="n">validate_output&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">validate_atc&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">example_atc_data_for_validation&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s">&amp;#34;atc_1&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">validate_output&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Validation Criteria:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Proper ATC code length and structure&lt;/li>
&lt;li>Character pattern verification&lt;/li>
&lt;li>Format compliance with WHO ATC standards&lt;/li>
&lt;/ul>
&lt;h3 id="validate_atc_by_reference">validate_atc_by_reference()&lt;/h3>
&lt;p>Checks if ATC codes &lt;strong>exist in a given reference list&lt;/strong> (e.g., WHO ATC index or validated datasets).&lt;/p>
&lt;p>&lt;strong>Usage:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-r" data-lang="r">&lt;span class="line">&lt;span class="cl">&lt;span class="n">validate_by_ref_output&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="nf">validate_atc_by_reference&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">example_atc_data_for_validation&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s">&amp;#34;atc_2&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">example_reference_data&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">validate_by_ref_output&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="combined-validation-workflow">Combined Validation Workflow&lt;/h3>
&lt;p>&lt;strong>Comprehensive validation&lt;/strong> using both format and reference checking:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-r" data-lang="r">&lt;span class="line">&lt;span class="cl">&lt;span class="n">output_combined&lt;/span> &lt;span class="o">&amp;lt;-&lt;/span> &lt;span class="n">example_atc_data_for_validation&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nf">validate_atc&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;atc_1&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">%&amp;gt;%&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nf">validate_atc_by_reference&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;atc_2&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">example_reference_data&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">output_combined&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Output Flags:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>&lt;code>atc_1_invalid&lt;/code>: Flag for invalid format (1 = invalid, 0 = valid)&lt;/li>
&lt;li>&lt;code>atc_2_invalid&lt;/code>: Flag for &amp;ldquo;not found in reference list&amp;rdquo; (1 = not found, 0 = found)&lt;/li>
&lt;/ul>
&lt;h2 id="understanding-drug_name_flag">Understanding drug_name_flag&lt;/h2>
&lt;p>The &lt;code>drug_name_flag&lt;/code> column provides &lt;strong>matching confidence&lt;/strong> in outputs from &lt;code>drug_match()&lt;/code> and &lt;code>drug_match_strip()&lt;/code>:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>0&lt;/strong>: First 3 characters of drug name match the first 3 of matched ATC code ✅&lt;/li>
&lt;li>&lt;strong>1&lt;/strong>: Mismatch detected between drug name and ATC prefix ⚠️&lt;/li>
&lt;/ul>
&lt;p>This flag helps identify potential matching errors and enables quality control in large datasets.&lt;/p>
&lt;h2 id="example-datasets">Example Datasets&lt;/h2>
&lt;p>atctools includes comprehensive example datasets for testing and learning:&lt;/p>
&lt;h3 id="example_drug_data">&lt;strong>example_drug_data&lt;/strong>&lt;/h3>
&lt;p>Drug names without dosage information for clean matching scenarios.&lt;/p>
&lt;h3 id="example_drug_data_with_mg">&lt;strong>example_drug_data_with_mg&lt;/strong>&lt;/h3>
&lt;p>Drug names with trailing dosage units (e.g., &amp;ldquo;paracetamol 500mg&amp;rdquo;) for strip matching.&lt;/p>
&lt;h3 id="example_atc_data">&lt;strong>example_atc_data&lt;/strong>&lt;/h3>
&lt;p>ATC codes for testing &lt;code>atc2drug()&lt;/code> – includes valid, invalid, and NA values.&lt;/p>
&lt;h3 id="example_reference_data">&lt;strong>example_reference_data&lt;/strong>&lt;/h3>
&lt;p>Reference dataset for drug name ↔ ATC code matching workflows.&lt;/p>
&lt;h3 id="example_atc_data_for_validation--new">&lt;strong>example_atc_data_for_validation&lt;/strong> ✨ New!&lt;/h3>
&lt;p>Contains ATC codes across multiple columns for testing both structural and reference-based validation.&lt;/p>
&lt;h2 id="installation">Installation&lt;/h2>
&lt;p>Install the development version directly from GitHub:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-r" data-lang="r">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># install.packages(&amp;#34;devtools&amp;#34;)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">devtools&lt;/span>&lt;span class="o">::&lt;/span>&lt;span class="nf">install_github&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;vljlangen/atctools&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="use-cases">Use Cases&lt;/h2>
&lt;p>Perfect for:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Pharmaceutical researchers&lt;/strong> standardizing drug classifications&lt;/li>
&lt;li>&lt;strong>Clinical data scientists&lt;/strong> validating medication datasets&lt;/li>
&lt;li>&lt;strong>Epidemiologists&lt;/strong> conducting drug utilization studies&lt;/li>
&lt;li>&lt;strong>Healthcare analysts&lt;/strong> ensuring data quality in EHR systems&lt;/li>
&lt;li>&lt;strong>Regulatory affairs&lt;/strong> professionals working with drug databases&lt;/li>
&lt;li>&lt;strong>Pharmacovigilance&lt;/strong> teams processing adverse event data&lt;/li>
&lt;/ul>
&lt;h2 id="key-updates--features">Key Updates &amp;amp; Features&lt;/h2>
&lt;h3 id="-new-validation-functions">✅ &lt;strong>New Validation Functions&lt;/strong>&lt;/h3>
&lt;ul>
&lt;li>&lt;code>validate_atc()&lt;/code> checks format validity against WHO standards&lt;/li>
&lt;li>&lt;code>validate_atc_by_reference()&lt;/code> verifies presence in reference datasets&lt;/li>
&lt;/ul>
&lt;h3 id="-enhanced-testing">🧪 &lt;strong>Enhanced Testing&lt;/strong>&lt;/h3>
&lt;ul>
&lt;li>New &lt;code>example_atc_data_for_validation&lt;/code> dataset&lt;/li>
&lt;li>Comprehensive validation workflow examples&lt;/li>
&lt;/ul>
&lt;h3 id="-improved-documentation">🔁 &lt;strong>Improved Documentation&lt;/strong>&lt;/h3>
&lt;ul>
&lt;li>Updated function examples with real-world scenarios&lt;/li>
&lt;li>Clear validation workflow documentation&lt;/li>
&lt;/ul>
&lt;h3 id="-performance-improvements">🧹 &lt;strong>Performance Improvements&lt;/strong>&lt;/h3>
&lt;ul>
&lt;li>Enhanced &lt;code>atc2drug()&lt;/code> function with better column detection&lt;/li>
&lt;li>Optimized matching algorithms for large datasets&lt;/li>
&lt;/ul>
&lt;h2 id="why-atctools">Why atctools?&lt;/h2>
&lt;p>Working with ATC codes manually is error-prone and time-consuming. atctools solves this by:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Automating matching&lt;/strong> between drug names and ATC codes&lt;/li>
&lt;li>&lt;strong>Ensuring data quality&lt;/strong> through comprehensive validation&lt;/li>
&lt;li>&lt;strong>Handling edge cases&lt;/strong> intelligently (dosage units, spelling variations)&lt;/li>
&lt;li>&lt;strong>Providing confidence metrics&lt;/strong> for quality control&lt;/li>
&lt;li>&lt;strong>Supporting research workflows&lt;/strong> with robust, tested functions&lt;/li>
&lt;/ul>
&lt;h2 id="technical-details">Technical Details&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Built for&lt;/strong>: R statistical computing environment&lt;/li>
&lt;li>&lt;strong>Specialty&lt;/strong>: Pharmaceutical and healthcare data analysis&lt;/li>
&lt;li>&lt;strong>Dependencies&lt;/strong>: Minimal dependencies for maximum compatibility&lt;/li>
&lt;li>&lt;strong>License&lt;/strong>: Open source (check repository for specific license)&lt;/li>
&lt;li>&lt;strong>Maintained&lt;/strong>: Actively developed with regular updates&lt;/li>
&lt;/ul>
&lt;h2 id="development--support">Development &amp;amp; Support&lt;/h2>
&lt;p>atctools is open source and welcomes contributions from the pharmaceutical data science community. Bug reports, feature requests, and pull requests are encouraged on the &lt;a href="https://github.com/vljlangen/atctools" target="_blank" rel="noopener">GitHub repository&lt;/a>.&lt;/p>
&lt;p>&lt;strong>Questions or issues?&lt;/strong> Feel free to reach out through the project&amp;rsquo;s GitHub issues page.&lt;/p>
&lt;p>Transform your pharmaceutical data workflows from manual, error-prone processes into automated, validated pipelines with atctools!&lt;/p></description></item></channel></rss>