GitHub Copilot

An introduction to AgenticAI assistants

August 23, 2025

Poll (raise your hands)

  • Who uses AI assistants (ChatGPT, Gemini, Claude, Mistral, …) on a daily basis?

  • Who uses AI assistants for code development, QC, or improving transparency and reproducibility in your research?

  • Who has ever used GitHub Copilot?

GitHub Copilot: Your AI Coding Assistant

What is GitHub Copilot?

  • AI-powered coding assistant by GitHub & OpenAI
  • Integrates with editors (VS Code, RStudio, etc.)
  • Suggests code, explains code, writes documentation, and more
  • Supports many languages (R, Python, SQL, etc.)

Disclaimer

COI

I do not have any financial or personal relationships with Microsoft or OpenAI that could influence the content of this presentation.

Some Important Notes Before We Dive In

  • AI is developing rapidly, so will GitHub Copilot
  • Copilot is not perfect; it can make mistakes
  • Always review suggestions carefully
    • See it as a helpful assistant/buddy, not a replacement to use your own intellect
  • Copilot does not replace human expertise (yet)
  • We will only cover the basics today
    • If you’d be intereted in a more advanced session, let us know via the course feedback form!

How to Access Copilot

  • Sign up: github.com/features/copilot
  • Requirements: GitHub account (free, subscription)
  • Install:
    • In VS Code: Extensions → Search “GitHub Copilot” → Install
    • In RStudio: Use the Copilot add-in (requires setup)
  • Activate: Sign in with your GitHub account

How does Copilot work?

Figure 1: Illustration of principle GitHub Copilot functionality.

Where Can You Access GitHub Copilot?

  • Visual Studio Code and GitHub Codespaces: Popular code editor with Copilot extension

Figure 2: GitHub Copilot extension in Visual Studio Code.

Where Can You Access GitHub Copilot?

  • RStudio: Integrated with RStudio for R development

Figure 3: GitHub Copilot in RStudio.

Where Can You Access GitHub Copilot?

Figure 4: GitHub Copilot in RStudio.

How to Use Copilot To Enhance Your Work in Pharmacoepidemiology

Use Cases for Analytic Code

Code comprehension & review

  • Ask Copilot to explain complex code
    • “Line coding is too long and complex” no longer a valid argument to not provide code along with a research study to enhance transparency and reproducibility (e.g., in peer-review)
  • Translate code between languages (e.g., R to Python)
  • Summarize code changes
  • Suggest improvements or catch potential bugs

Code development, testing and documentation

  • Write new functions, scripts, or analyses faster
  • Generate boilerplate code for data import, cleaning, modeling
  • Create unit tests for your functions (!!!)
  • Suggest test cases (simulated data) and edge scenarios
  • Auto-generate docstrings, comments, and README content

Use Cases for git

GitHub Copilot for Git

  • Automate common git workflows
    • Example: generate commit messages based on code changes (git diff)
  • Tracking
    • “What changes were made to this repository in the last 5 commits?”
  • Staging & committing
  • Advanced usage (create branches, help with pull requests and merging, etc.)

Copilot Modes

Figure 5: Overview of Copilot modes available in VSCode.

Prompt engineering

  • Be specific and clear in your prompts
  • Provide context and examples
  • Iterate on prompts based on feedback

Copilot in Action (Ask Mode)

“To illustrate an application of the approach, we created and analyzed an active comparator new user cohort. Briefly, we implemented an active comparator new user design comparing the risk of bladder cancer of sodium–glucose co-transporter 2 (SGLT-2) inhibitors and glucagon-like peptide 1 receptor agonists (GLP-1RAs) inspired by a recent study from Abrahami et al.2 […]”

Copilot in Action (Ask Mode)

Copilot in Action (Edit Mode)

Copilot in Action (Agent Mode)

Copilot in Action (Agent Mode)

Example: Simulate dataset based on published literature Dataset: xxx randomized trial Publication: NCTID:

Copilot in Action (Git Workflow)

Questions?

Give it a try in your next project!

References

1.
Abdelaziz AI, Hanson KA, Gaber CE, Lee TA. Optimizing large real-world data analysis with parquet files in r: A step-by-step tutorial. Pharmacoepidemiology and Drug Safety 2024; 33: e5728.
2.
Abrahami D, Tesfaye H, Yin H, et al. Sodium–glucose cotransporter 2 inhibitors and the short-term risk of bladder cancer: An international multisite cohort study. Diabetes Care 2022; 45: 2907–2917.