Installation of TCseq package
BiocManager::install("TCseq")
preparation of TCA dataframe
-
Count matrix
data.csv -
Sample information
edesign.csv -
Chromatin information
gene_info.csv
### loading the package
library(TCseq)
###TCA formation
genomicIntervals <- read.csv('chromatin_info.csv', stringsAsFactors = FALSE)
genomicIntervals$chr <- as.factor(genomicIntervals$chr)
countsTable <- read.csv('count_matrix.csv', header = T, row.names = 1)
countsTable <- as.matrix(countsTable)
experiment <- read.csv('sample_info.csv', header = T, stringsAsFactors = FALSE)
experiment$sampleid <- as.factor(experiment$sampleid)
tca <- TCA(design = experiment, genomicFeature = genomicIntervals, counts = countsTable)
###Data filtering and DEG analysis
tca <- DBanalysis(tca, filter.type = "raw", filter.value = 10, samplePassfilter = 2)
DBres.sig <- DBresult(tca, group1 = "0h", group2 = c("6h", "1d", ...), top.sig = TRUE)
str(DBres.sig, strict.width = "cut")
###Analysis on the trend over time
tca <- timecourseTable(tca, value = "FC", norm.method = "rpkm", filter = TRUE, control.group = "ctrl") ###for count analysis
tca <- timecourseTable(tca, value = "expression", norm.method = "rpkm", filter = TRUE, control.group = "ctrl") ###for RPKM analysis, recommended
###Clustering
set.seed(123)
cluster_num <- 6
tca <- timeclust(tca, algo = 'cm', k = cluster_num, standardize = TRUE)
p <- timeclustplot(tca, value = 'z-score', cols = 3, axis.line.size = 0.6,
axis.title.size = 8, axis.text.size = 8, title.size = 8, legend.title.size = 8, legend.text.size = 8)
###Total number of included genes in each cluster
table(tca@clusterRes@cluster)
###Output
cluster_list <- as.data.frame(tca@clusterRes@cluster)
membership <- as.data.frame(tca@clusterRes@membership)
cluster_info <- merge(cluster_list, membership, by = "row.names", sort = F)
write.csv(cluster_info, "cluster_info.csv", row.names = F)
The list of clustering should be proceed to further enrichment and annotation.
Alternative methods of "kmeans" clustering
p_load(pheatmap)
p <- pheatmap(matrix, scale = "row", kmeans_k = 6, border = F,
color = colorRampPalette(c("navy", "white", "firebrick3"))(50),
gaps_col = c(3,6), cluster_cols = F, angle_col = 45)
cluster <- as.data.frame(p$kmeans$cluster)
网友评论