简体   繁体   中英

How to reduce dimension of gene expression matrix by calculating correlation coefficients?

I am in interested in finding Pearson correlation coefficients between a list of genes. Basically, I have Affymetrix gene level expression matrix (genes in the rows and sample ID on the columns), and I have annotation data of microarray experiment observation where sample ID in the rows and description identification on the columns.

data

> expr_mat[1:8, 1:3]
             Tarca_001_P1A01 Tarca_003_P1A03 Tarca_004_P1A04
1_at                6.062215        6.125023        5.875502
10_at               3.796484        3.805305        3.450245
100_at              5.849338        6.191562        6.550525
1000_at             3.567779        3.452524        3.316134
10000_at            6.166815        5.678373        6.185059
100009613_at        4.443027        4.773199        4.393488
100009676_at        5.836522        6.143398        5.898364
10001_at            6.330018        5.601745        6.137984

> anodat[1:8, 1:3]
               V1   V2    V3
1        SampleID   GA Batch
2 Tarca_001_P1A01   11     1
3 Tarca_013_P1B01 15.3     1
4 Tarca_025_P1C01 21.7     1
5 Tarca_037_P1D01 26.7     1
6 Tarca_049_P1E01 31.3     1
7 Tarca_061_P1F01 32.1     1
8 Tarca_051_P1E03 19.7     1

goal :

I intend to see how the genes in each sample are correlated with GA value of corresponding samples in the annotation data, then generate sub expression matrix of keeping high correlated genes with target observation data anodat$GA .

my attempt :

gene_corrs <- function(expr_mat, anno_mat){
    stopifnot(ncol(expr_mat)==nrow(anno_mat))
    res <- list()
    lapply(colnames(expr_mat), function(x){
        lapply(x, rownames(y){
            if(colnames(x) %in% rownames(anno_mat)){
                cor_mat <- stats::cor(y, anno_mat$GA, method = "pearson")
                ncor <- ncol(cor_mat)
                cmatt <- col(cor_mat)
                ord <- order(-cmat, cor_mat, decreasing = TRUE)- (ncor*cmatt - ncor)
                colnames(ord) <- colnames(cor_mat)
                res <- cbind(ID=c(cold(ord), ID2=c(ord)))
                res <- as.data.frame(cbind(out, cor=cor_mat[res]))
                res <- cbind(res, cor=cor_mat[out])
                res <- as.dara.frame(res)
            }
        })
    })
    return(res)
}

however, my above implementation didn't return what I expected, I need to filter out the genes by finding genes which has a strong correlation with anodat$GA .

Another attempt :

I read few post about similar issue and some people discussed about using limma package. Here is my attempt by using limma . Here I used anodat$GA as a covariate to fit limma linear model:

library(limma)
fit <- limma::lmFit(expr_mat, design = model.matrix( ~ 0 + anodat$GA)
fit <- eBayes(fit)
topTable(fit, coef=2)

then I am expecting to get a correlation matrix from the above code, and would like to do following in order to get filtered sub expression matrix:

idx <- which( (abs(cor) > 0.8) & (upper.tri(cor)), arr.ind=TRUE)
idx <- unique(c(idx[, 1],idx[, 2])
correlated.genes <- matrix[idx, ]

but I still didn't get the right answer. I am confident about using limma approach but I couldn't figure out what went wrong above code again. Can anyone point me out how to make this work? Is there any efficient way to make this happen?

Don't have your data so hard to double check, but in the abstract I would try this:

library(matrixTests)
cors <- row_cor_pearson(expr_mat, anodat$GA)

which(cors$cor > 0.9)  # to get the indeces of genes with correlation > 0.9

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM