Hello I'm a new bioinformatician so bear with me please!
I'm using the gprofiler2 to run GO/KEGG analysis in R using emacs/ess and I want to add a title to the table it offers:
publish_gosttable(gostres, highlight_terms = gostres$result[c(1:2,10,120),],
use_colors = TRUE,
show_columns = c("source", "term_name", "term_size", "intersection_size"),
filename = NULL)
I have tried the title(), tab_header() function but I can't seem to be able to add a title. My question is if there is some other function or package that would allow me to add it instead of having to do it manually.
The code so far
GOresult <- gost(
geneid1up$gene,
organism = "hsapiens",
ordered_query = FALSE,
multi_query = FALSE,
significant = TRUE,
exclude_iea = FALSE,
measure_underrepresentation = FALSE,
evcodes = FALSE,
user_threshold = 0.05,
correction_method = "gSCS",
domain_scope = "annotated",
custom_bg = NULL,
numeric_ns = "",
sources = c("GO:BP","GO:MF","GO:CC","KEGG"),
as_short_link = FALSE)
GOresult1 <- as.data.frame(GOresult$result)
GOresult1$minuslog10pval <- -log10(GOresult1$p_value)
names(GOresult1)[15] <- "-log10(pval)"
GOresult2 <- GOresult1[order(GOresult1$p_value, decreasing=F),]
plot1 <- publish_gosttable(GOresult2, highlight_terms = GOresult2[c(1:20),],
use_colors = FALSE,
show_columns = c("source", "term_name", "term_size", "intersection_size","-log10(pval)"),
filename = NULL)
Does this do the job?
library(gprofiler2)
library(ggplot2)
gostres <- gost(query = c("X:1000:1000000", "rs17396340", "GO:0005005", "ENSG00000156103", "NLRP1"),
organism = "hsapiens", ordered_query = FALSE,
multi_query = FALSE, significant = TRUE, exclude_iea = FALSE,
measure_underrepresentation = FALSE, evcodes = FALSE,
user_threshold = 0.05, correction_method = "g_SCS",
domain_scope = "annotated", custom_bg = NULL,
numeric_ns = "", sources = NULL, as_short_link = FALSE)
publish_gosttable(gostres, highlight_terms = gostres$result[c(1:2,10,120),],
use_colors = TRUE,
show_columns = c("source", "term_name", "term_size", "intersection_size"),
filename = NULL)+
ggtitle('Your Title')
Result:
The trick is that the plot is a ggplot objet. Therefore you can add the title using +ggtitle('Your Title') after your plot code (as in my example)
Related
I am using RevoScaleR rxDataStep function in RStudio to write data to a SQL table. The process works fine yet I am unable to save the output from the reportProgress argument when set to any value, 2 or 3. The results show up in the Console but I can't figure out where the objects exist so I can save them for future use. How can I save the progress outputs?
out <- rxDataStep(inData = data, outFile = obj, varsToKeep = NULL, varsToDrop = NULL,
rowSelection = NULL, transforms = NULL, transformObjects = NULL,
transformFunc = NULL, transformVars = NULL,
transformPackages = NULL, transformEnvir = NULL,
append = "rows", overwrite = TRUE, rowVarName = NULL,
removeMissingsOnRead = FALSE, removeMissings = FALSE,
computeLowHigh = TRUE, maxRowsByCols = 50000000,
rowsPerRead = -1, startRow = 1, numRows = -1,
returnTransformObjects = F,
blocksPerRead = 10000,
reportProgress = 2)
This is what shows up in console:
Rows Processed: 100Total Rows written: 100, Total time: 0.384
Maybe this is a more general R console question, how to save any message from the console which is not available otherwise
I am using a function "lp_lin_panel" from the package "lpirfs", for example:
hor3.1_h <- lp_lin_panel(data_set = panel_3 , data_sample = "Full" , endog_data = "E.tertiary", cumul_mult = TRUE , shock = "lv18_bank_c", diff_shock = FALSE , iv_reg = FALSE , instrum = NULL , panel_model = "within" , panel_effect = "individual" , robust_cov = "vcovSCC" , use_gmm = FALSE, gmm_model = "onestep", gmm_transformation = "d", c_exog_data = cv_3_h, l_exog_data = NULL, confint = 1.96 , hor = 6 )
When I use the command:
plot(hor3.1_h , main = NULL)
I still get an automatic title in the plot. Like this
Is there another way to remove it?
Thank you
Try to use:
plot(hor3.1_h) + labs(title = "")
I used the bibliometrix function in R, and want to plot some useful graphs.
library(bibliometrix)
??bibliometrix
D<-readFiles("E:\\RE\\savedrecs.txt")
M <- convert2df(D,dbsource = "isi", format= "plaintext")
results <- biblioAnalysis(M ,sep = ";" )
S<- summary(object=results,k=10, pause=FALSE)
plot(x=results,k=10,pause=FALSE)
options(width=100)
S <- summary(object = results, k = 10, pause = FALSE)
NetMatrix <- biblioNetwork(M1, analysis = "co-occurrences", network = "author_keywords", sep = ";")
S <- normalizeSimilarity(NetMatrix, type = "association")
net <- networkPlot(S, n = 200, Title = "co-occurrence network",type="fruchterman", labelsize = 0.7, halo = FALSE, cluster = "walktrap",remove.isolates=FALSE, remove.multiple=FALSE, noloops=TRUE, weighted=TRUE)
res <- thematicMap(net, NetMatrix, S)
plot(res$map)
But in the net <- networkPlot(S, n = 200, Title = "co-occurrence network",type="fruchterman", labelsize = 0.7, halo = FALSE, cluster = "walktrap",remove.isolates=FALSE, remove.multiple=FALSE, noloops=TRUE, weighted=TRUE), it shows error
Error in V<-(*tmp*, value = *vtmp*) : invalid indexing
. Also I cannot do the CR, it always shows unlistCR. I cannot use the NetMatrix function neither.
Some help me plsssssssss
The problem is in the data itself not in the code you presented. When I downloaded the data from bibliometrix.com and changed M1 to M (typo?) in biblioNetwork function call everything worked perfectly. Please see the code below:
library(bibliometrix)
# Plot bibliometric analysis results
D <- readFiles("http://www.bibliometrix.org/datasets/savedrecs.txt")
M <- convert2df(D, dbsource = "isi", format= "plaintext")
results <- biblioAnalysis(M, sep = ";")
S <- summary(results)
plot(x = results, k = 10, pause = FALSE)
# Plot Bibliographic Network
options(width = 100)
S <- summary(object = results, k = 10, pause = FALSE)
NetMatrix <- biblioNetwork(M, analysis = "co-occurrences", network = "author_keywords", sep = ";")
S <- normalizeSimilarity(NetMatrix, type = "association")
net <- networkPlot(S, n = 200, Title = "co-occurrence network", type = "fruchterman",
labelsize = 0.7, halo = FALSE, cluster = "walktrap",
remove.isolates = FALSE, remove.multiple = FALSE, noloops = TRUE, weighted = TRUE)
# Plot Thematic Map
res <- thematicMap(net, NetMatrix, S)
str(M)
plot(res$map)
I am currently running a stacked species distribution model through a linux cluster using the following code:
library(SSDM)
setwd("/home/nikhail1")
Env <- load_var(path = getwd(), files = NULL, format = c(".grd", ".tif",
".asc",
".sdat", ".rst", ".nc",
".envi", ".bil", ".img"), categorical = "af_anthrome.asc",
Norm = TRUE, tmp = TRUE, verbose = TRUE, GUI = FALSE)
Occurrences <- load_occ(path = getwd(), Env, file =
"Final_African_Bird_occurrence_rarefied_points.csv",
Xcol = "decimallon", Ycol = "decimallat", Spcol =
"species", GeoRes = FALSE,
sep = ",", verbose = TRUE, GUI = FALSE)
head(Occurrences)
warnings()
SSDM <- stack_modelling(c("GLM", "GAM", "MARS", "GBM", "RF", "CTA",
"MAXENT", "ANN", "SVM"), Occurrences, Env, Xcol = "decimallon",
Ycol = "decimallat", Pcol = NULL, Spcol = "species", rep = 1,
name = "Stack", save = TRUE, path = getwd(), PA = NULL,
cv = "holdout", cv.param = c(0.75, 1), thresh = 1001,
axes.metric = "Pearson", uncertainty = TRUE, tmp = TRUE,
ensemble.metric = c("AUC", "Kappa", "sensitivity",
"specificity"), ensemble.thresh = c(0.75, 0.75, 0.75, 0.75), weight = TRUE,
method = "bSSDM", metric = "SES", range = NULL,
endemism = NULL, verbose = TRUE, GUI = FALSE, cores = 200)
save.stack(SSDM, name = "Bird", path = getwd(),
verbose = TRUE, GUI = FALSE)
I receive the following error message when trying to run my analyses:
Error in socketConnection("localhost", port = port, server = TRUE, blocking
= TRUE, :
all connections are in use
Calls: stack_modelling ... makePSOCKcluster -> newPSOCKnode ->
socketConnection
How do i increase the maximum number of connections? Can i do this within the SSDM package as parallel is built in. Do I have to apply a specific function from another package to ensure that my job runs smoothly across clusters?
Thank you for you help,
Nikhail
The maximum number of open connections you can have in R is 125. To increase the number of connections you can have open at the same time, you need to rebuild R from source. See
https://github.com/HenrikBengtsson/Wishlist-for-R/issues/28
I am trying to generate a bar plot with this data:
library(sjPlot)
library(sjstats)
data("efc")
i use the following to generate the default xtab plot from the sjPlot.
sjp.xtab(x = efc$e42dep,
grp = efc$c82cop1)
But i prefer show only a "cleanest" plot, without information (i prefer to link to a table if you want the specific data), so i try this:
sjp.xtab(x = efc$e42dep,
grp = efc$c82cop1,show.total = F, show.n = F,show.prc = F)
but i get this
Error in sjp.xtab(x = efc$e42dep, grp = efc$c82cop1, show.total = F,
show.n = F, : objeto 'ggvaluelabels' no encontrado
i use R in a Spanish language OS, so...
is basically
object 'ggvaluelabels' not found
What am i doing wrong?
use show.values = FALSE to prevent annotating the graph.
sjp.xtab(x = efc$e42dep, grp = efc$c82cop1)
# show.values = FALSE
sjp.xtab(x = efc$e42dep, grp = efc$c82cop1, show.values = FALSE )
sjp.xtab(x = efc$e42dep, grp = efc$c82cop1,show.total = F, show.n = F,show.prc = F, show.values = FALSE)