Skip to content

Commit

Permalink
Lint R files
Browse files Browse the repository at this point in the history
  • Loading branch information
memgonzales committed May 4, 2023
1 parent 35a5fec commit d43aa1d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"editor.defaultFormatter": "ms-python.autopep8",
"editor.formatOnSave": true
},
"[r]": {
"editor.defaultFormatter": "REditorSupport.r",
"editor.formatOnSave": true
},
"python.formatting.provider": "none",
"editor.codeActionsOnSave": {
"source.organizeImports": true
Expand Down
36 changes: 20 additions & 16 deletions enrichment_analysis/kegg-enrichment.r
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ background <- background[[1]]
genes_transcript <- c()
na_genes_transcript <- c()
for (gene in genes) {
transcript_id <- RiceIDConvert(gene, fromType = 'MSU', toType = 'TRANSCRIPTID')
transcript_id <- RiceIDConvert(gene, fromType = "MSU", toType = "TRANSCRIPTID")
for (id in transcript_id$TRANSCRIPTID) {
if (is.na(id)) {
print(gene)
Expand All @@ -23,13 +23,13 @@ for (gene in genes) {
}
}

lapply(na_genes_transcript, write, 'data/cluster1-na-transcript-id.txt', append = T, sep = '\n')
lapply(genes_transcript, write, 'data/cluster1-transcript-id.txt', append = T, sep = '\n')
lapply(na_genes_transcript, write, "data/cluster1-na-transcript-id.txt", append = TRUE, sep = "\n")
lapply(genes_transcript, write, "data/cluster1-transcript-id.txt", append = TRUE, sep = "\n")

background_transcript <- c()
na_background_transcript <- c()
for (gene in background) {
transcript_id <- RiceIDConvert(gene, fromType = 'MSU', toType = 'TRANSCRIPTID')
transcript_id <- RiceIDConvert(gene, fromType = "MSU", toType = "TRANSCRIPTID")
for (id in transcript_id$TRANSCRIPTID) {
if (is.na(id)) {
print(gene)
Expand All @@ -40,21 +40,25 @@ for (gene in background) {
}
}

lapply(na_background_transcript, write, 'data/all-na-transcript-id.txt', append = T, sep = '\n')
lapply(background_transcript, write, 'data/all-transcript-id.txt', append = T, sep = '\n')
lapply(na_background_transcript, write, "data/all-na-transcript-id.txt", append = TRUE, sep = "\n")
lapply(background_transcript, write, "data/all-transcript-id.txt", append = TRUE, sep = "\n")

kegg <- enrichKEGG(gene = genes_transcript,
universe = background_transcript,
organism = "dosa",
keyType = "kegg",
kegg <- enrichKEGG(
gene = genes_transcript,
universe = background_transcript,
organism = "dosa",
keyType = "kegg",
)

kegg_df <- as.data.frame(kegg)
write.table(kegg_df, "data/kegg_df.txt", sep="\t", row.names=FALSE, quote=FALSE)
write.table(kegg_df, "data/kegg_df.txt", sep = "\t", row.names = FALSE, quote = FALSE)

p1 <- dotplot(kegg, showCategory = nrow(kegg_df),
title = "Top 10 most statistically significant enriched KEGG terms",
font.size = 10)
p1 <- dotplot(kegg,
showCategory = nrow(kegg_df),
title = "Top 10 most statistically significant enriched KEGG terms",
font.size = 10
)
ggsave(p1,
filename = "data/kegg_dotplot.png",
height = 22,width = 22,units = "cm")
filename = "data/kegg_dotplot.png",
height = 22, width = 22, units = "cm"
)
10 changes: 5 additions & 5 deletions enrichment_analysis/msu-to-transcript-id.r
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ all_transcript <- c()
na_all_transcript <- c()

for (gene in all_genes) {
transcript_id <- RiceIDConvert(gene, fromType = 'MSU', toType = 'TRANSCRIPTID')
transcript_id <- RiceIDConvert(gene, fromType = "MSU", toType = "TRANSCRIPTID")
transcript_id_list <- c()
transcript_id_list <- append(transcript_id_list, gene)

for (id in transcript_id$TRANSCRIPTID) {
if (is.na(id)) {
print(gene)
Expand All @@ -20,9 +20,9 @@ for (gene in all_genes) {
transcript_id_list <- append(transcript_id_list, id)
}
}

all_transcript <- append(all_transcript, list(transcript_id_list))
}

lapply(na_all_transcript, write, 'data/temp/all-na-transcript-id.txt', append = T, sep = '\n')
lapply(all_transcript, write, 'data/temp/all-transcript-id.txt', append = T, sep = '\n')
lapply(na_all_transcript, write, "data/temp/all-na-transcript-id.txt", append = TRUE, sep = "\n")
lapply(all_transcript, write, "data/temp/all-transcript-id.txt", append = TRUE, sep = "\n")

0 comments on commit d43aa1d

Please sign in to comment.