Skip to content

mmabry/MU_Lewis_Introduction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

1. Logging into Lewis

http://docs.rnet.missouri.edu/getting-started

To log into Lewis, type the following in a local terminal:

ssh <username>@lewis.rnet.missouri.edu

2. Basic Linux Commands

http://docs.rnet.missouri.edu/Linux/basic-commands

Basic commands

--help Used with a command to get info on syntax/options. Ex: ls --help

man Gives access to the 'man pages' or 'manual pages'. Ex: man ls

pwd Prints the full pathname of the file or directory

up arrow Hitting the up arrow on your keyboard will display the last run command

history Outputs all previously used commands

tab complete To complete a command without typing the full command hit tab

control+c To kill the foreground process hit control+c

clear Refresh screen, also can use control+l

Files

cat Used to make files, redirect files, and to read the contents of a file

ls Used to list files and directories Ex: ls -l gives you more info, ls -lh makes it human readable size numbers

cp Used to copy

mv Used to move files

rm -i Used to remove files

mkdir Used to make new directories

less Used to paginate text. Ex: less job_output.txt

3. SLURM Overview

http://docs.rnet.missouri.edu/SLURM/slurm

Example Batch SLURM job

nano saving_the_world.sh
#! /bin/bash

#SBATCH -p Lewis  # use the Lewis partition
#SBATCH -J saving_the_world  # give the job a custom name
#SBATCH -o results-%j.out  # give the job output a custom name
#SBATCH -t 0-02:00  # two hour time limit

#SBATCH -N 1  # number of nodes (you will most likely never need more than 1 node)
#SBATCH -n 2  # number of cores (AKA tasks)

# Commands here run only on the first core
echo "$(hostname), reporting for duty."

# Commands with srun will run on all cores in the allocation
srun echo "Let's save the world!"
srun hostname
sbatch saving_the_world.sh

check out your results file!

checking job status

sacct or squeue with flags -u <username> or -j <job id>

scancel cancels jobs with flags -u <username> or -j <job id>

4. Rstudio on Lewis

http://docs.rnet.missouri.edu/Software/r-studio

log out of lewis and log back in using adding -YC after ssh

  • macOS X - Download and Install XQuartz and then add the -YC flags to your ssh command when connecting to Lewis
  • Windows 10 - MobaXterm will provide X11 support by default
ssh -YC <username>@lewis.rnet.missouri.edu
srun -p Interactive --mem 4G --pty /bin/bash
module load rstudio/rstudio-desktop-1.1.456
rstudio

https://www.tidyverse.org/packages/

install.packages("tidyverse")
library(tidyverse)

Iris Dataset Visualization

A. load the iris dataset that is already located in R. We can use the head() command to look at the first five columns.

data("iris")
head(iris)
> head(iris)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa

B. Using summary() we can check the statistic summary of our iris data.

summary(iris)
> summary(iris)
  Sepal.Length    Sepal.Width     Petal.Length    Petal.Width   
 Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100  
 1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300  
 Median :5.800   Median :3.000   Median :4.350   Median :1.300  
 Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199  
 3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800  
 Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500  
       Species  
 setosa    :50  
 versicolor:50  
 virginica :50

C. Let's plot our data to see the relation between these features using the ggplot() function.

  • First we can check the relation between Sepal length and Sepal width
  • we use theme_minimal() here to adjust the appearance of the plots
ggplot(data=iris,aes(x=Sepal.Width, y=Sepal.Length)) + 
   geom_point() + 
   theme_minimal()
  • we can also add a title and change the xy axis labels by adding ggtitle("your title here"), xlab("label for x axis") & ylab("label for y axis").

D. Now we would like to see this relation by each species. To do this we can pass a additional aesthetic to our ggplot, which marks the species by different colors.

ggplot(data=iris,aes(x=Sepal.Width, y=Sepal.Length, color=Species)) + 
    geom_point() + 
    theme_minimal() 

E. On top of this scatter plot, we can add a trend line to visualize the general trend. We do this by adding geom_smooth().

  • passing argument se=False turns off confidence intervals
ggplot(data=iris,aes(x=Sepal.Width, y=Sepal.Length, color=Speceis)) + 
    geom_point() +
    geom_smooth(se=FALSE) +
    theme_minimal()
  • is there something wrong with your code? What do you think is wrong?

F. We can also divide the plot into multiple plots, one for each species by adding facet_wrap().

ggplot(data=iris,aes(x=Sepal.Width, y=Sepal.Length, color=Species)) +
    geom_point() + 
    geom_smooth(se=FALSE) +
    facet_wrap(~Species) +
    theme_minimal()
  • try saving image in your home working directory.

G. Let's look at boxplots!

ggplot(data=iris,aes(x=Species, y=Petal.Length, color=Species)) + 
    geom_boxplot() +
    theme_minimal()+
    theme(legend.position="none")
  • We can understand the feature (here Petal.Length) easily by looking at the boxplot. The thick black line represents median, the edges of box represent 25th and 75th quantiles. The dot represents outliers.

H. You can plot frequency using a histogram.

ggplot(data=iris,aes(x=Sepal.Length, fill=Species)) + 
    geom_histogram() +
    theme_minimal()

I. We can again split the plots like we did with the scatterplot with facet_wrap().

ggplot(data=iris,aes(x=Sepal.Length, fill=Species)) + 
    geom_histogram() +
    theme_minimal() +
    facet_wrap(~Species)

5. Keep learning!

About

Introduction to the MU lewis sever and R studio

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published