Table of Contents |
---|
...
Open RStudio (you can type it in the Windows search bar)
Create a new R script: ‘File’ → “New File” → “R script”
Save this script where your samples folders are (‘File’ → ‘Save’). These should be on your H or W drive. Save the script file as ‘scrnaseq.R’
In the following sections you will be copying and running the R code into your scrnaseq.R script.
Cell Ranger (and nfcore/scrnaseq) generates a default folder and file output structure. There will be a main folder that contains all the sample subfolders (NOTE: this is where you must save your R script). Each sample folder will have an ‘outs’ subfolder. This ‘outs’ folder contains a ‘filtered_feature_bc_matrix’ folder, which contains the files that Seurat uses in its analysis.
...
You can manually set your working directory in RStudio by selecting ‘Session' -> 'Set working directory' -> 'Choose directory'. Choose the same directory as you saved your scrnaseq.R script, previous section. This will output the setwd(...)
command with your working directory into the console window (bottom left panel). Copy this command to replace the default setwd(...)
line in your R script.
...
Code Block |
---|
#### 2g. Processing expression data (dimensionality reduction) #### # Normalise data mat3 <- NormalizeData(mat2) # Identification of variable features mat3 <- FindVariableFeatures(mat3, selection.method = "vst", nfeatures = nrow(mat3)) # Scaling the data all.genes <- rownames(mat3) mat3 <- ScaleData(mat3, features = all.genes) # Perform linear dimensional reduction (PCA) mat3 <- RunPCA(mat3, features = VariableFeatures(object = mat3)) |
2h. Plot of highly variable genes
Using the FindVariableFeatures
results, we can visualise the most highly variable genes, including a count of variable and non variable genes in your dataset. The below code ouputs the top 10 genes, but you can ajust this number as desired (i.e. in top_genes <- head(VariableFeatures(mat3), 10)
change 10
to another number).
...