Hello everyone, I am struggling to get an FPKM matrix using countToFPKM library. everything seems running here is my script I get error.
library("devtools") library("biomaRt") library("dplyr") library(countToFPKM) file.readcounts<- as.matrix(read.csv("Matrix.csv", header = TRUE, row.names = 1)) nrow(file.readcounts) ens_build = "sep2015" dataset="hsapiens_gene_ensembl" mart <- useEnsembl(biomart = "ENSEMBL_MART_ENSEMBL", dataset = dataset, version = 80) gene.annotations <- biomaRt::getBM(mart = mart, attributes=c("ensembl_gene_id", "external_gene_name", "start_position", "end_position")) gene.annotations <- dplyr::transmute(gene.annotations, external_gene_name, ensembl_gene_id, length = end_position - start_position) convert order column in gene.annotation and make first column as row.name # Filter and re-order gene.annotations to match the order in feature counts matrix gene.annotations <- gene.annotations %>% dplyr::filter(gene.annotations$ensembl_gene_id %in% row.names(file.readcounts)) gene.annotations <- gene.annotations[order(match(gene.annotations$ensembl_gene_id, rownames(file.readcounts))),] # Assign feature lenghts into a numeric vector. featureLength <- gene.annotations$length
the future length seems to be ok as integer value but at the end here is the error
fpkm_matrix <- fpkm (file.readcounts, featureLength=featureLength, meanFragmentLength=NULL) Error in fpkm(file.readcounts, featureLength = featureLength, meanFragmentLength = NULL) : length(featureLength) == nrow(counts) is not TRUE
I can't understand the error the match function seems working fine...
I accept any help, thank you