├── .gitignore ├── Courses ├── Git+R.md ├── RMarkdown_basics.md └── vignette.png ├── R ├── GitHub_Tutorial.Rproj └── my_amazing_script.R └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | .DS_Store -------------------------------------------------------------------------------- /Courses/Git+R.md: -------------------------------------------------------------------------------- 1 | # Git+R, the best combo you can dream of 2 | 3 | In theory, you've installed Git+R. If it is not the case, you have a great tutorial [here](https://www.geo.uzh.ch/microsite/reproducible_research/post/rr-rstudio-git/) to install it for your machine. 4 | 5 | ❌ From now on, you will never ever open a single R script and lose it due to your disorganized workplace.\ 6 | ✅ In the upper side of your window, go to File > New Project > Version Control. 7 | 8 | If you are a good practicer, you will get this window opened:\ 9 | ![alt text](https://experimentalbehaviour.files.wordpress.com/2018/01/screenshot6.png?w=578) 10 | 11 | Here you will get two options: 12 | - Either you want to look at a script from a fantastic paper you've discovered 13 | - Or you want to start a new project on your own (it requires a Github account! ⚠️) 14 | 15 | **:one: First option**\ 16 | In the former, you will copy and paste the URL of the repository in the first field. 17 | In our case, you want to get this repository on your laptop because you've spotted a mistake, and you want to correct it. How good you are! 😇\ 18 | The URL will be: ``https://github.com/JayCrlt/GitHub_Tutorial``\ 19 | The second field will be filled automatically and will be named as I chose, e.g. ``GitHub_Tutorial`` 20 | The third and last field will be very personal according to how you organize your workplace – It is up to you! 21 | You will get the repository in your laptop. I hope both markdowns can help you to organize your thoughts. 22 | 23 | **:two: Second option**\ 24 | The second option is far more interesting. Let's say R is not very your friend 😒, but, hey, you're an ecologist 🌱, you have to deal with it! 🤭 25 | But how about you have a good friend of yours that can give you a hand with a tricky problem? Or what about starting a project with several people, and each of you gets a task to do on R, people A, B, and C are curing the data, people D and E will do the ecological analysis, and people F will define an ambitious mathematical model. So far, you can tell me: "Yes, once people A, B and C are done, they'll send the data to people D, E and F". Yeah, that's an option. Until person A figures out that he made a mistake and everything will likely change 🤯 26 | 27 | ![alt](https://thinkr.fr/wp-content/uploads/git_notfinal.gif) 28 | 29 | At this very moment, you can feel that GitHub will be a powerful tool for efficiency 🤩 30 | 31 | ## So, how does that work? Let's practice! 32 | 33 | I will ask you to create a new project called as you want. I won't give you a hint of how to call it because I want you to share it later.\ 34 | However, I can recall that you have to create your project in [``GitHub``](https://github.com) to get the URL.\ 35 | It would be easier for the first time to make your repository public. But, 36 | Once your project is created in GitHub, you can link it to your R project. 37 | You will get a folder. Remember, into this folder, it would be great to have the following: 38 | - a ``R subfolder`` :file_folder: 39 | - a ``Data subfolder`` :file_folder: 40 | - a ``Results subfolder`` :file_folder: 41 | 42 | You can now open a new R script called as you want again, e.g. `my_script.R` 43 | And now, you will be able to open a new script into this project: New file > R script and for the fantasy: 44 | 45 | ```{Session Info, echo = T} 46 | library(ggplot2) 47 | my_amazing_data <- iris 48 | ggplot(my_amazing_data) + 49 | geom_point(aes(x = Sepal.Length, y = Sepal.Width, fill = Species), shape = 21) + 50 | scale_fill_manual(values = c("red", "blue", "green")) + 51 | theme_classic() 52 | ``` 53 | 54 | You might like to change it slightly, using Petal.Length instead of Sepal.Length. 55 | Or maybe you might just want to change the colors. Make some changes or build a new plot to amaze your mates. 56 | 57 | Then, you will save your script as usual. You're almost done!\ 58 | You might notice on the top a section GIT, with the GIT logo. Clicking on it, you will find a sub-section ``Commit...``.\ 59 | Select the documents you want to upload, and fill in the field ``Commit message`` – This is mandatory! ⚠️\ 60 | And then Push! ⬆️ 61 | 62 | From now on, your script appears to be online and accessible to everyone.\ 63 | NB: If you chose a private repository, only your collaborators might see it. 64 | 65 | By the way, It would be awesome to add some mates you want to collaborate with, don't you think? 😉\ 66 | You might find a collaborator section in the GitHub Settings (from your repository).\ 67 | Your collaborator will pull ⬇️ your project and do some corrections. Let's say he does not like the colors and will change them. However, you are colorblind and cannot appreciate the changes made. Spoiler alert 🤭: here is one of the best features that GitHub can provide. You will notice a ``history`` section in the commit section; click on it. All the commits are listed, and you can go backwards if a change doesn't please you. Isn't it amazing? 🤩 68 | 69 | ⚠️ Each time a change has been made from a collaborator, you will have to pull first before pushing. Otherwise, it might not work. 70 | 71 | Now you are ready to collaborate more efficiently. I hope it was crystal clear and it has helped you. If it is the case, feel free to star this repository and to spread the word to the entire world! 🌍 -------------------------------------------------------------------------------- /Courses/RMarkdown_basics.md: -------------------------------------------------------------------------------- 1 | # RMarkDown Basics 2 | 3 | This document is a ``RMarkdown``.\ 4 | It will be presented at the beginning, and can / **should** be used to explain to your readers the purpose of this repository. 5 | 6 | Because you are working in ecology :seedling:, one of the best use you can do, is to use a GitHub Repository to store: 7 | - Your Data :memo: 8 | - Your Code :computer: 9 | - Your Figures :bar_chart: 10 | 11 | Note that you can use emojis to be more friendly.\ 12 | You have two options; if you know the [emoji code](https://gist.github.com/rxaviers/7360908), then you can use it. For example, if you want a folder, you can use the code `:file_folder:`. If you don't know the code, you can still copy/paste from an [emoji website](https://getemoji.com).\ 13 | You can also refer some keywords to another page using brackets and the URL. To do so, put brackets around the word, or the group of words you want to highlight, followed by the URL in parenthesis. 14 | 15 | There are plenty of ways to help your reader and to make your repository fancier. If you're not used to ``RMarkdown``, I recommend having a look at [RMarkdown Cheat Sheet](https://www.markdownguide.org/cheat-sheet/) 16 | 17 | You can also make tables, in certain cases, if you feel the need. 18 | Below I show you a silly example, but it can be terrific for data curation use (e.g. [here](https://github.com/JWicquart/gcrmndb_benthos)) 19 | 20 | **Table 1.** Silly example 21 | People | Age | Size | 22 | --------:|:--------:|:--------| 23 | Jérémy | 30 yrs | 173 cm | 24 | Valentin | 28 yrs | 176 cm | 25 | 26 | # A well-structured Rmakdown README is key for reproducibity 27 | 28 | But one of the highest strengths of ``RMarkdown``, is that you can write down some ideas or start writing down even for a meeting presentation, including (or not) your R analysis and your outputs. Most of the time, you will work with chunks. If you are interested, we can work on this during another tutorial. 29 | 30 | If I mentioned the chunks, it's because I highly suggest launching in the console the ``sessionInfo()`` function once your final R script is done. Then you can copy/paste the different pieces of information into a triple `` ` ``.\ 31 | It will highly help the reproducibility of your analyse with your pairs. 32 | 33 | ```{Session Info, echo = T} 34 | R version 4.2.1 (2022-06-23) 35 | Platform: x86_64-apple-darwin17.0 (64-bit) 36 | Running under: macOS Monterey 12.2.1 37 | 38 | Matrix products: default 39 | LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib 40 | 41 | locale: 42 | [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 43 | 44 | attached base packages: 45 | [1] stats graphics grDevices utils datasets methods base 46 | ``` 47 | 48 | It is worth to build some hierarchy into your repository,\ 49 | I recommend getting always: 50 | - a single ``R`` folder :file_folder:, hosting for your RProj and your R scripts. 51 | - a single ``Data`` folder :file_folder:, hosting for your data you are willing to share. 52 | - a single ``Results`` folder :file_folder:, hosting for your raw or edited Figures. 53 | 54 | [Here](https://github.com/JayCrlt/CCA_Methods) is an example of a perfectly reproducible repository. 55 | 56 | From here, we can move on and work directly with a case study using R: [``Tutorial R+Git``](https://github.com/JayCrlt/GitHub_Tutorial/blob/main/Courses/Git%2BR.md) -------------------------------------------------------------------------------- /Courses/vignette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JayCrlt/GitHub_Tutorial/45277a7913a9a1e1a20337fcb4085f02bf4f5060/Courses/vignette.png -------------------------------------------------------------------------------- /R/GitHub_Tutorial.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /R/my_amazing_script.R: -------------------------------------------------------------------------------- 1 | library(ggplot2) 2 | my_amazing_data <- iris 3 | my_colors <- c("brown3", "cornflowerblue", "darkgreen") 4 | ggplot(my_amazing_data, aes(x = Sepal.Length, y = Sepal.Width, fill = Species)) + 5 | geom_point(shape = 21, size = 4) + 6 | scale_fill_manual(values = my_colors) + scale_color_manual(values = my_colors) + 7 | geom_smooth(formula = y~x, aes(color = Species), method = 'lm') + 8 | scale_x_continuous(name = "Sepal length (cm)", limits = c(4,8)) + 9 | scale_y_continuous(name = "Sepal width (cm)", limits = c(2,5)) + 10 | facet_wrap(~Species) + 11 | theme_dark() 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub tutorial 2 | 3 | This tutorial is presented by [Jérémy Carlot](https://jaycrlt.github.io), as a result of his post-doctoral fellowship with the [Laboratoire d'Océanographie de Villefranche sur mer](https://lov.imev-mer.fr/web/) at [IMEV](https://www.imev-mer.fr/web/#) in France and supervised by [Nuria Teixido](https://orcid.org/0000-0001-9286-2852), [Steeve Comeau](https://orcid.org/0000-0002-6724-5286) and [Jean-Pierre Gattuso](https://orcid.org/0000-0002-4533-4114). 4 | 5 | Participants in 2023: 6 | - [Jordi Boada](https://orcid.org/0000-0002-3815-625X) 7 | - [Diego Moreno Moran](https://orcid.org/0009-0007-2796-2313) 8 | - [Elisabet Nebot-Colomer](https://orcid.org/0000-0003-1013-2405) 9 | - [Jana Verdura](https://orcid.org/0000-0003-0662-1206) 10 | - [Steeve Comeau](https://orcid.org/0000-0002-6724-5286) 11 | - [Frederic Gazeau](https://orcid.org/0000-0001-8807-4597) 12 | - [Nuria Teixido](https://orcid.org/0000-0001-9286-2852) 13 | - [Flavio Picone](https://orcid.org/0000-0001-6903-9665) 14 | - Mégane Ballin 15 | - Romane Torchy 16 | 17 | Participants in 2024: 18 | - Gaia Grasso 19 | - Abril Karla Hernandez Ramirez 20 | 21 | --- 22 | 23 | ## RMarkDown Basics 24 | 25 | This document is a ``RMarkdown``.\ 26 | It will be presented at the beginning, and can / **should** be used to explain to your readers the purpose of this repository. 27 | 28 | Because you are working in ecology :seedling:, one of the best use you can do, is to use a GitHub Repository to store: 29 | - Your Data :memo: 30 | - Your Code :computer: 31 | - Your Figures :bar_chart: 32 | 33 | Note that you can use emojis to be more friendly.\ 34 | You have two options; if you know the [emoji code](https://gist.github.com/rxaviers/7360908), then you can use it. For example, if you want a folder, you can use the code `:file_folder:`. If you don't know the code, you can still copy/paste from an [emoji website](https://getemoji.com).\ 35 | You can also refer some keywords to another page using brackets and the URL. To do so, put brackets around the word, or the group of words you want to highlight, followed by the URL in parenthesis. 36 | 37 | There are plenty of ways to help your reader and to make your repository fancier. If you're not used to ``RMarkdown``, I recommend having a look at [RMarkdown Cheat Sheet](https://www.markdownguide.org/cheat-sheet/) 38 | 39 | You can also make tables, in certain cases, if you feel the need. 40 | Below I show you a silly example, but it can be terrific for data curation use (e.g. [here](https://github.com/JWicquart/gcrmndb_benthos)) 41 | 42 | **Table 1.** Silly example 43 | People | Age | Size | 44 | --------:|:--------:|:--------| 45 | Jérémy | 30 yrs | 173 cm | 46 | Valentin | 28 yrs | 176 cm | 47 | 48 | ## A well-structured Rmakdown README is key for reproducibity 49 | 50 | But one of the highest strengths of ``RMarkdown``, is that you can write down some ideas or start writing down even for a meeting presentation, including (or not) your R analysis and your outputs. Most of the time, you will work with chunks. If you are interested, we can work on this during another tutorial. 51 | 52 | If I mentioned the chunks, it's because I highly suggest launching in the console the ``sessionInfo()`` function once your final R script is done. Then you can copy/paste the different pieces of information into a triple `` ` ``.\ 53 | It will highly help the reproducibility of your analyse with your pairs. 54 | 55 | ```{Session Info, echo = T} 56 | R version 4.2.1 (2022-06-23) 57 | Platform: x86_64-apple-darwin17.0 (64-bit) 58 | Running under: macOS Monterey 12.2.1 59 | 60 | Matrix products: default 61 | LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib 62 | 63 | locale: 64 | [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 65 | 66 | attached base packages: 67 | [1] stats graphics grDevices utils datasets methods base 68 | ``` 69 | 70 | It is worth to build some hierarchy into your repository,\ 71 | I recommend getting always: 72 | - a single ``R`` folder :file_folder:, hosting for your RProj and your R scripts. 73 | - a single ``Data`` folder :file_folder:, hosting for your data you are willing to share. 74 | - a single ``Results`` folder :file_folder:, hosting for your raw or edited Figures. 75 | 76 | [Here](https://github.com/JayCrlt/CCA_Methods) is an example of a perfectly reproducible repository. 77 | 78 | From here, we can move on and work directly with a case study using R: [``Tutorial R+Git``](https://github.com/JayCrlt/GitHub_Tutorial/blob/main/Courses/Git%2BR.md) 79 | --------------------------------------------------------------------------------