Varibility analysis in R - II: Genotypic and Phenotypic correlation

 The blog is second part of a series of three blogs related to variability analysis using R software. The blog demonstrates utilization of variability package available in R for calculating genotypic and phenotypic correlation among traits in one line of code. (Reading time 7 min.)

Before heading further to read this blog it is highly recommended to go through first blog Variability analysis in R - I: Genetic parameters .Reading the first blog will give an idea about how to arrange the data in excel sheet, import the data in RStudio and install the package named variability required for the analysis.

R Script for Genotypic correlation 

Lines in blue are script. Type these blue lines and press Ctrl+Enter run the lines.
Open a new script by clicking on New and than selecting R script or by pressing Ctrl+Shift+N.
 
In our first blog we have seen that SFR trait had shown negative genotypic variance & we need to drop that trait from data set. In order to do that there are two ways:
  1. In the excel sheet delete the SFR column and again import the data set to RStudio
  2. Remove SFR column in RStudio only. Lets see how to do that.  
The SFR trait is located on 6th column and we need to remove that. 
vardata1<-vardata[-6]
This will remove the 6th column in vardata and store it by the name vardata1. Well you can keep the same name i.e., vardata also, its up to you. 
 
library(variability)
library() will load variability package
 
?geno.corr
geno.corr is the function for calculating genotypic correlation. To know more about this function run the ?geno.corr

geno.corr(vardata1[3:8],vardata1$Genotypes,vardata1$Replication)

The variability package has a function named geno.corr() which will allow us to estimate genetypic correlation. Let me breakdown this line

geno.corr is our function belonging to variability package

vardata1[3:8] here square bracket are used for indexing. 3:8 means our data is located from column 3 to column 8 in "vardata1" dataset

vardata1$Genotypes is used to use genotypes as an input. R will look for a column named Genotypes in vardata1 dataset

vardata1$Replication is used to use replication as an input. R will look for a column named Replication in vardata1 dataset

Output

$GenotypicCorrelation
     PH         LL        MRP        GRW        DRWR       GRY       
PH   1 **       0.784 **  -0.2232 NS 0.4351 *   -0.5959 ** 0.4245 *  
LL   0.784 **   1 **      0.159 NS   0.1553 NS  -0.432 *   0.1435 NS 
MRP  -0.2232 NS 0.159 NS  1 **       0.784 **   -0.414 *   0.7738 ** 
GRW  0.4351 *   0.1553 NS 0.784 **   1.0001 **  -0.8175 ** 1 **      
DRWR -0.5959 ** -0.432 *  -0.414 *   -0.8175 ** 1 **       -0.8151 **
GRY  0.4245 *   0.1435 NS 0.7738 **  1 **       -0.8151 ** 1 **      

$Note1
[1] "The sig of genotypic correlation was tested using t test (two-tail). The degree of freedom used is number of genotypes - 2"

$Note2
[1] "If NaNs are produced checkout for negative genotypic variance for one or more traits"
 
You can see the output in console. Select the output and copy paste it in word or text format as per your requirement.

R Script for Phenotypic correlation

?pheno.corr
pheno.corr is the function for calculating phenotypic correlation. To know more about this function run the above mentioned line

pheno.corr(vardata1[3:8],vardata1$Genotypes,vardata1$Replication)

The variability package has a function named pheno.corr() which will allow us to estimate phenotypic correlation. Let me explain the above code

pheno.corr is our function belonging to variability package for calculating phenotypic correlation

vardata1[3:8] here square bracket are used for indexing. 3:8 means our data is located from column 3 to column 8 in "vardata1" dataset

vardata1$Genotypes is used to use genotypes as an input. R will look for a column named Genotypes in vardata1 dataset

vardata1$Replication is used to use replication as an input. R will look for a column named Replication in vardata1 dataset

Output

$PhenotypicCorrelation
     PH         LL        MRP        GRW        DRWR       GRY       
PH   1 **       0.6373 ** 0.05 NS    0.3227 *   -0.4363 ** 0.3225 *  
LL   0.6373 **  1 **      0.0156 NS  0.1562 NS  -0.2915 *  0.1546 NS 
MRP  0.05 NS    0.0156 NS 1 **       0.4711 **  -0.1961 NS 0.4747 ** 
GRW  0.3227 *   0.1562 NS 0.4711 **  1 **       -0.7632 ** 0.9994 ** 
DRWR -0.4363 ** -0.2915 * -0.1961 NS -0.7632 ** 1 **       -0.7616 **
GRY  0.3225 *   0.1546 NS 0.4747 **  0.9994 **  -0.7616 ** 1 **      

$Note
[1] "The sig of phenotypic correlation was tested using t test (two-tail). The degree of freedom used is (genotypes*replication) - 2"
 
Select the output available in console and copy paste it in word or text format as per your requirement.
 
Enjoy the learning!

If you are using the variability R package in research work you can cite it as:
Raj Popat, Rumit Patel and Dinesh Parmar (2020). variability: Genetic Variability Analysis for Plant Breeding Research. R package version 0.1.0.https://CRAN.R-project.org/package=variability

Topics you might be interested in 

Variability analysis in R - I: Genetic parameters

Variability analysis in R - III: Genotypic Path Analysis

Comments

  1. Many thanks indeed for your highly educative presentations. However I do have a challenge and I will appreciate for kind assistance. I am having genotypic correlation values far above 1. I cannot seem to find out where the problem is. What may be responsible for this?

    ReplyDelete
    Replies
    1. For this look at the anova for that trait. Carefully exam if the genotpye source ms is significant or not and what its magnitude in comaprison to the error ms? This will help you to figure out the problem.

      Delete

Post a Comment

Popular posts from this blog

Estimation of Genetic Parameters in Plant Breeding: Theory, Example and Demonstration in AgriAnalyze tool

F test: Theory, Solved Example and Demonstration in Agri Analyze