This document accompanies the DIYtranscriptomics course and is intended to provide basic guidance in how use the AI-powered utility, Github Copilot, to accelerate your work in R and RStudio
Github Copilot is a generative AI tool referred to as a âpair programmerâ. This means that it works with you to create code. Under the hood, Copilot is using the OpenAI Codex model that is trained on billions of lines of code from virtually every coding language. This makes it an incredibly powerful tool to assist you in your day-to-day coding tasks. Normally, Copilot requires a monthly or annual paid subscription, but the tool is free to students. Unfortunately, itâs not obvious how to access this tool, so Iâve provided some instructions below for you to follow.
- Get the Github Student Development Pack
- Connect Copilot to your Github account
- Turn on Copilot in RStudio
- Start coding using Copilot
- Tips and suggestions
Get the Github Student Development Pack
Follow the steps below to gain access to the Github Student Development Pack, which includes many useful tools and perks, including Github Copilot.
- Visit the Github student developer main page
- Sign Up for the student developer pack
- Select âGet Student Benefitâ
- Sign-in to your GitHub account. If you donât have a Github account, register for a free one now.
- Add your school email. This process usually needs some authentication, because a code will be sent to your school email for verification.
- Enter the name of your school
- Answer the questions on how you plan to use GitHub.
- On some occasions, more proof might be required. So you might need to upload either of school identity card or any other form of proof of study validity.
- Submit the application. In many cases the approval occurs within seconds to minutes
Connect Copilot to your Github account
Now you're ready to connect Copilot to your Github account. To do this, go to the Copilot website and log in.
Then, go to your user icon (upper right) and choose âSettingsâ from the drop down menu
Once on the settings page, click on Co-pilot in the left hand menu and confirm that you have successfully linked co-pilot to your github account
Turn on Copilot in RStudio
Now that you have Copilot linked to your github account, you need to link RStudio to your Github account and turn on Copilot in RStudio.
Open RStudio and from the main menu choose Tools â Global Options
From the pop-up window that opens choose Copilot from the left-hand menu
Start coding using Copilot
With Copilot now turned on, you will see âsuggestedâ code and comments listed in light grey âghostedâ and italicized text. If you donât like the suggestion you see, simply keep typing and the suggestion will disappear. However, if you like the suggestion, hit âtabâ on your keyboard the suggestion becomes part of your script!
Tips and suggestions
- Rethink the purpose of code comments. Comments now become prompts for the AI algorithm.
- The âIntroductionâ code chunk should provide a high level description of what it is you hope to accomplish with this script. This gives Copilot some necessary scope and helps inform that kind of suggestions youâll be receiving
- if you donât like the Copilot suggestion, try modifying your prompt to be more specific (this is called prompt engineering)
- If youâre not a native english speaker, thatâs OK. Copilot is multilingual!
- Copilot, like any AI tools right now, will get things wrong. For example, Copilot might suggest using a variable or function that doesnât even exist. Check the suggestions. Even wrong suggestions can still be useful.
- Like a plot you already made? Use copilot to iterate on this. For example, âmake the last plot interactiveâ
- Copilot uses a technique called neighboring tabs that allows the AI pair programmer to contextualize your code by processing all of the files open in your IDE instead of just the single file youâre working on
- If you modify some suggested code, Copilot will learn from this. For example, if the suggested code creates an object called âfileâ and you change to âfile_01â, then the next time Copilot suggests creating an object, it will suggest âfile_02â.