Thank you for the help.
The abundance files seem fine. It is the txi.kallisto file that has this issue.
The txi.kallisto$counts looks like below when aligning to the cdna+ncRNA:
The abundance file looks like this:
When I align just to cDNA i get the below:
My code is below:
## For multiple samples, each named as a folder in the kallisto directory (can be abundance.h5 or abundance.tsv file)
accessions <- list.dirs(full.names=FALSE)[-1]
kallisto.dir<-paste0(accessions)
kallisto.files<-file.path(kallisto.dir,"abundance.tsv") #can also be abundance.tsv
names(kallisto.files)<- accessions
# standard ensembl biomaRt attributes
transcript_id <- "ensembl_transcript_id"
gene_id <- "ensembl_gene_id"
gene_name <- "external_gene_name"
mart <- biomaRt::useMart("ensembl", "dmelanogaster_gene_ensembl", host = "ensembl.org")
t2g2 <- biomaRt::getBM(attributes = c(transcript_id, gene_name), mart = mart)
t2g2 <- dplyr::rename(t2g2, target_id = transcript_id, ext_gene = gene_name)
t2g2[nrow(t2g2) + 1,] <- list('EGFP', 'EGFP')
head(t2g2)
tail(t2g2)
txi.kallisto <- tximport(kallisto.files, type = "kallisto", tx2gene = t2g2[,c(1,2)], ignoreTxVersion = TRUE)
head(txi.kallisto$counts)
gene_counts = round(txi.kallisto$counts)
head(gene_counts)
getwd()
gene_tpm = txi.kallisto$abundance
write.table( gene_counts, file="est_counts_genes_kallisto.txt", sep="\t", row.names=T, quote=F)
write.table( gene_tpm, file="tpm_values_genes_kallisto.txt", sep="\t", row.names=T, quote=F)
The only difference in the code between the cDNA and cDNA+ncRNA alignment is that in the latter I added t2g2[nrow(t2g2) + 1,] <- list('EGFP', 'EGFP') to the code.