Use of clusterProfiler : Error in testForValidKeytype(x, keytype) - r

I don't know if you have already encountered this kind of problem with clusterProfiler, but it seems that it doesn't recognize the keytype I indicate.
Having GIDs, indicating keyType="GID" as an argument, I get this error:
> GOenrich <- enrichGO(gene=GenesVector,
+ OrgDb="org.Cgigas.eg.db",
+ keyType="GID",
+ ont="BP",
+ pAdjustMethod="BH",
+ qvalueCutoff="0.05",
+ universe=GenesBackground,
+ readable=FALSE,
+ pool=FALSE)
Error in testForValidKeytype(x, keytype) :
Invalid keytype: GOALL. Please use the keytypes method to see a listing of valid arguments.
When I display the list of possible arguments, I get the following result:
> keytypes(org.Cgigas.eg.db)
[1] "EVIDENCE" "GID" "GO"
However, the same error is displayed for keyType="GO" or keyType="EVIDENCE", even though these arguments are not relevant to my study.
If you are using clusterProfiler and have any advice, I am listening.
For precision: I generated my Org.db using the makeOrgPackage() function of AnnotationForge.

Related

TypeError: argmax(): argument 'input' (position 1) must be Tensor, not str

My code was working fine and when I tried to run it today without changing anything I got the following error:
TypeError: argmax(): argument 'input' (position 1) must be Tensor, not str
Would appreciate if help could be provided.
below is the code snippet where I am getting an error. I am using BERT mdoel
start_scores, end_scores = model(torch.tensor([input_ids]), # The tokens representing our input text.
token_type_ids=torch.tensor(
[segment_ids])) # The segment IDs to differentiate question from answer_text
# ======== Reconstruct Answer ========
# Find the tokens with the highest `start` and `end` scores.
answer_start = torch.argmax(start_scores)
answer_end = torch.argmax(end_scores)
In your line of code
start_scores, end_scores = model(torch.tensor([input_ids]),token_type_ids=torch.tensor([segment_ids]))
you have to make it:
start_scores, end_scores = model(torch.tensor([input_ids]),token_type_ids=torch.tensor([segment_ids]), return_dict=False).
It worked for me. I had the same problem.

Error in if (more || nchar(output) > 80) when using mgcv

I have the same problem with this one but no solutions found yet
.
Error in if (more || nchar(output) > 80) { : missing value where TRUE/FALSE needed
I am conducting analysis using the mgcv package.
model1<-gam(fm_xsetz~total_pm2.5, data=analysis)
I can get the results by using the summary(). But when I try to open the model in the global environment, I get the warning:
Error in if (more || nchar(output) > 80) { : missing value where
TRUE/FALSE needed
Is anyone has the same problem?
FYI,when you use the following code:
library(geostatsp)
data(swissRain)
same problem happens!
I have/had a similar problem when I tried to view a List generated trough a function that computes the intersect/difference of two sets of 23000 observations each.
The function in question:
jeepers.creepers<-function(dfx,dfy,by.x,by.y){
SetX<-dfx[[by.x]]
SetY<-dfy[[by.y]]
Union.X.Y<-intersect(SetX,SetY)
Difference.in.X<-setdiff(SetX,Union.X.Y)
Difference.in.Y<-setdiff(SetY,Union.X.Y)
result<-list(Union.X.Y,Difference.in.X,Difference.in.Y)
names(result)<-c("Union of SetX and SetY",
"Unique in SetX",
"Unique in SetY")
return(result)
}
It gave me this error:
Error in if (more || nchar(output) > 80) { :
missing value where TRUE/FALSE needed
Nevertheless I could view the elements individually with
View(list$element)
I had a similar problem yet I could view it with:
view(as.data.frame(df))

Scilab - gui - many unknown variables error messages

Still trying to understand the logic of Scilab, I created a small calculation tool for a mechanical element. The main problem I have is finding the right order (or syntax) for the calculation code... I get a lot of "unknown variable" errors and I don't understand why?
I tried to change the order of definitions for the functions, declare the variables as global, etc. but nothing seems to help.
The code for the calculation is not long and also not complicated, but the gui was built using guibuilder, so the uicontrols definitions are probably much longer than they need to be.
Could somebody help me make this code working, as I would learn and understand a lot by this example, althought it contains more than one "problem zones"?
Here what I've done:
G = 78500;
table_titles = ["" "Wire diameter" "Wp" "Tau alwd" "M alwd" "Angle alwd"];
f=figure('figure_position',[910,163],'figure_size',
[903,537],'auto_resize','on','background',[33],'figure_name','Graphic
window number %d');
//////////
delmenu(f.figure_id,gettext('File'))
delmenu(f.figure_id,gettext('?'))
delmenu(f.figure_id,gettext('Tools'))
toolbar(f.figure_id,'off')
handles.dummy = 0;
handles.sl_dwire=uicontrol(f,'unit','normalized','BackgroundColor',
[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma',
'FontSize',[12],'FontUnits','points','FontWeight','normal',
'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',
[],'Max',[12],'Min',[0],'Position',
[0.0058208,0.77875,0.124375,0.06875],'Relief','default','SliderStep',
[0.1,1],'Style','slider','String',"Wire diameter",'Value',
[6],'VerticalAlignment','middle','Visible','on','Tag','sl_dwire',
'Callback','sl_dwire_callback(handles)')
handles.ed_dwire=uicontrol(f,'unit','normalized','BackgroundColor',
[-1,-1,-1],'Enable','off','FontAngle','normal','FontName','Tahoma',
'FontSize',[12],'FontUnits','points','FontWeight','normal',
'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',
[],'Max',[1],'Min',[0],
'Position',[0.0058208,0.71875,0.124375,0.06875],'Relief',
'default','SliderStep',[0.01,0.1],'String',"wire diameter: " +
msprintf('%2.1f',handles.sl_dwire.Value) + "mm",'Style','text',
'Value',[0],'VerticalAlignment','middle','Visible','on','Tag',
'ed_dwire','Callback','auto')
handles.sl_wangle=uicontrol(f,'unit','normalized','BackgroundColor',
[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma',
'FontSize',[12],'FontUnits','points','FontWeight','normal',
'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left',
'ListboxTop',[],'Max',[180],'Min',[5],'Position',
[0.0090625,0.5191667,0.25625,0.0645833],'Relief','default',
'SliderStep',[0.1,1],'String','Working angle','Style','slider','Value',
[50],'VerticalAlignment','middle','Visible','on','Tag','sl_wangle',
'Callback','sl_wangle_callback(handles)')
handles.ed_wangle=uicontrol(f,'unit','normalized','BackgroundColor',
[-1,-1,-1],'Enable','off','FontAngle','normal','FontName','Tahoma',
'FontSize',[12],'FontUnits','points','FontWeight','normal',
'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left',
'ListboxTop',[],'Max',[1],'Min',[0],'Position',
[0.0090625,0.4591667,0.25625,0.0645833],'Relief','default',
'SliderStep',[0.01,0.1],'String',"Working angle: " +
msprintf('%2.1f',handles.sl_wangle.Value) + "°",'Style','text',
'Value',[0],'VerticalAlignment','middle','Visible','on','Tag',
'ed_wangle','Callback','auto')
handles.sl_activel=uicontrol(f,'unit','normalized',
'BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal',
'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight',
'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left',
'ListboxTop',[],'Max',[1000],'Min',[10],'Position',
[0.0090625,0.365,0.25625,0.0645833],'Relief','default',
'SliderStep',[0.1,1],'String','Active length' ,'Style','slider',
'Value',[10],'VerticalAlignment','middle','Visible','on','Tag',
'sl_activel','Callback','sl_activel_callback(handles)')
handles.ed_activel=uicontrol(f,'unit','normalized',
'BackgroundColor',[-1,-1,-1],'Enable','off','FontAngle','normal',
'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight',
'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left',
'ListboxTop',[],'Max',[1],'Min',[0],'Position',
[0.0090625,0.305,0.25625,0.0645833],'Relief','default',
'SliderStep',[0.01,0.1],'String','Active length: ' +
msprintf('%2.1f',handles.sl_activel.Value) +
"mm",'Style','text','Value',[0],'VerticalAlignment','middle','Visible',
'on','Tag','ed_activel','Callback','auto')
handles.ax_graph= newaxes();handles.ax_graph.margins = [ 0 0 0 0];
handles.ax_graph.axes_bounds = [0.4274266,0.0619266,0.3995485,0.5191743];
handles.tab_param=uicontrol(f,'unit','normalized','BackgroundColor',
[-1,-1,-1],'Enable','on','FontAngle','normal','FontName',
'Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal',
'ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left',
'ListboxTop',[],'Max',[1],'Min',[0],
'Position',[0.4308126,0.1690826,0.3950339,0.2178899],'Relief',
'default','SliderStep',[0.01,0.1],'String',string(table_param),'Style',
'table','Value',[0],'VerticalAlignment','middle','Visible',
'on','Tag','tab_param','Callback','tab_param_callback(handles)')
handles.sl_sfactor=uicontrol(f,'unit','normalized',
'BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal',
'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight',
'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left',
'ListboxTop',[],'Max',[1],'Min',[0],
'Position',[0.0058208,0.6525688,0.124375,0.06875],'Relief','default',
'SliderStep',[0.01,0.1],'String',"Safety factor",'Style',
'slider','Value',[0.58],'VerticalAlignment','middle','Visible','on',
'Tag','ed_sfactor','Callback','sl_sfactor_callback(handles)')
handles.ed_sfactor=uicontrol(f,'unit','normalized',
'BackgroundColor',[-1,-1,-1],'Enable','off','FontAngle','normal',
'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight',
'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment',
'left','ListboxTop',[],'Max',[1],'Min',[0],'Position',
[0.0058208,0.5925688,0.124375,0.06875],'Relief','default',
'SliderStep',[0.01,0.1],'String',"Safety factor : " +
msprintf('%2.1f',handles.sl_sfactor.Value),'Style',
'text','Value',[0.58],'VerticalAlignment','middle','Visible','on',
'Tag','ed_dwire','Callback','auto')
handles.popm_wtype=uicontrol(f,'unit','normalized',
'BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal',
'FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight',
'normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left',
'ListboxTop',[],'Max',[1],'Min',[0],'Position',
[0.0058208,0.8618349,0.124375,0.0639450],'Relief','default',
'SliderStep',[0.01,0.1],'String',gettext("SL/DL|SM/DM|SH/DH"),'Style',
'popupmenu','Value',[2],'VerticalAlignment','middle','Visible','on',
'Tag','popm_wtype','Callback','popm_wtype_callback(handles)')
//////////
// Callbacks are defined as below. Please do not delete the comments
as it will be used in coming version
//////////
function sl_sfactor_callback(handles)
sf=handles.sl_sfactor.Value;
handles.ed_sfactor.String="Safety factor: " + msprintf('%3.2f',sf);
endfunction
function sl_dwire_callback(handles)
wd=handles.sl_dwire.Value;
Wp = %pi*wd^3/16;
Ip =%pi*wd^4/32;
Kt = G*%pi*Ip/(180*L);
Talwd = sf * calcform;
Malwd = Wp * Talwd;
alphaalwd = Malwd / Kt;
x=0:0.1:alphaalwd*1.5;
plot(x,Kt*x);
handles.ed_dwire.String="Wire diameter: " +
msprintf('%2.1f',wd) + "mm";
endfunction
function popm_wtype_callback(handles)
//Write your callback for popm_wtype here
if selected == 1 then
calcform =(1845 - 700*log10(wd));
elseif selected == 2 then
calcform =(2105 - 780*log10(wd));
elseif selected == 3 then
calcform = (2220 - 820*log10(wd));
end
endfunction
function sl_wangle_callback(handles)
handles.ed_wangle.String="Working angle: " +
msprintf('%2.1f',handles.sl_wangle.Value) + "°";
endfunction
function sl_activel_callback(handles)
//Write your callback for sl_activel here
handles.ed_activel.String="Active length: " +
msprintf('%2.1f',handles.sl_activel.Value) + "mm";
L=handles.sl_activel.Value;
endfunction
function tab_param_callback(handles)
//Write your callback for tab_param here
table_values = string([ wd Wp Talwd Malwd alphaalwd]);
table_param = [table_titles; [table_values]];
endfunction
I expect the code to dynamically update the graph and the parameters table according to the positions of input sliders and popup-menu.
Again, it would be very helpful if somebody could help me get this code working, as I would get answers for a lot of my questions concerning programming with scilab.
Thank you very much in advance!
First of all, your code is not directly executable, caused by the linebreaks. Please add ... after each line of a statement. This improves also the readability.
As mentioned by #luispauloml, you try to use variables, which exist just inside of another function. For example you try to reach table_param, which is just alive in tab_param_callback(handles).
To get rid of this, you have to define the output for the function:
function [table_values, table_param] = tab_param_callback(handles)
table_values = string([ wd Wp Talwd Malwd alphaalwd]);
table_param = [table_titles; [table_values]];
endfunction
Now you can call this function to get the variable:
string(tab_param_callback(handles))
I corrected just this case and added the dots as explained. For the other variables, it can be done analogously. Furthermore, I moved the function definition to the beginning of the code. Because if your scrips crashed in the middle, the compiler has no chance to read the function definitions.
Please find the code in this file .
I hope this helps. Good luck!

python creation json with plone object

I've a json file with plone objects and there is one field of the objects giving me an error:
UnicodeDecodeError('ascii', '{"id":"aluminio-prata", "nome":"ALUM\xc3\x8dNIO PRATA", "num_demaos":0, "rendimento": 0.0, "unidade":"litros", "url":"", "particular":[], "profissional":[], "unidades":[]},', 36, 37, 'ordinal not in range(128)') (Also, the following error occurred while attempting to render the standard error message, please see the event log for full details: 'NoneType' object has no attribute 'getMethodAliases')
I already know witch field is, is the "title" from title = obj.pretty_title_or_id(), when I remove it from here its ok:
json += '{"id":"' + str(id) + '", "nome":"' + title + '", "num_demaos":' + str(num_demaos) + ', "rendimento": ' + str(rendimento) + ', "unidade":"' + str(unidade) + '", "url":"' + link_produto + '", "particular":' + arr_area_particular + ', "profissional":' + arr_area_profissional + ', "unidades":' + json_qtd + '},
but when I leave it I've got this error.
UnicodeDecodeError('ascii', '{"id":"aluminio-prata", "nome":"ALUM\xc3\x8dNIO PRATA", "num_demaos":0, "rendimento": 0.0, "unidade":"litros", "url":"", "particular":[], "profissional":[], "unidades":[]},', 36, 37, 'ordinal not in range(128)') (Also, the following error occurred while attempting to render the standard error message, please see the event log for full details: 'NoneType' object has no attribute 'getMethodAliases')
I'm going to assume that the error occurs when you're reading the JSON file.
Internally, Plone uses Python Unicode strings for nearly everything. If you read a string from a file, it will need to be decoded into Unicode before Plone can use it. If you give no instructions otherwise, Python will assume that the string was encoded as ASCII, and will attempt its Unicode conversion on that basis. It would be similar to writing:
unicode("ALUM\xc3\x8dNIO PRATA")
which will produce the same kind of error.
In fact, the string you're using was evidently encoded with the UTF-8 character set. That's evident from the "\xc3", and it also makes sense, because that's the character set Plone uses when it sends data to the outside world.
So, how do you fix this? You have to specify the character set that you wish to use when you convert to Unicode:
"ALUM\xc3\x8dNIO PRATA".decode('UTF8')
This gives you a Python Unicode string with no error.
So, after you've read your JSON file into a string (let's call it mystring), you will need to explicitly decode it by using mystring.decode('UTF8'). unicode(mystring, 'UTF8') is another form of the same operation.
As Steve already wrote do title.decode('utf8')
An Example illustrate the facts:
>>> u"Ä" == u"\xc4"
True # the native unicode char and escaped versions are the same
>>> "Ä" == u"\xc4"
False # the native unicode char is '\xc3\x84' in latin1
>>> "Ä".decode('utf8') == u"\xc4"
True # one can decode the string to get unicode
>>> "Ä" == "\xc4"
False # the native character and the escaped string are
# of course not equal ('\xc3\x84' != '\xc4').
I find this Thread very helpfull for Problems and Understanding with Encode/Decode of UTF-8.

r :Error: could not find function -User defined

I am trying to run the below simple function in R studio
a<-testfunc15(state,outcome)
{
st<-state
out<-outcome
print(st)
tempdff<-healthcareoutcome[healthcareoutcome$State==st,]
tempdff
}
When i copy and paste of the R prompt of the R studio ,i get an error :
Error: could not find function "testfunc15"
> {
+
+ st<-state
+ out<-outcome
+ print(st)
+ tempdff<-healthcareoutcome[healthcareoutcome$State==st,]
+ tempdff
+
+ }
Error: object 'state' not found
when i try to source it :source("testfunc15.R")
then i get this error :
Error in eval(expr, envir, enclos) : could not find function"testfunc15"
I am saving the file in the same getwd() as other functions ,other functions are working fine.
Where am i going wrong ?
I couldn't find an answer on stackoverflow though there were many questions with the same description.
Please help
The first line of your code is telling R to store the result of testfunc15(state, outcome) in a. It is not defining the function.
Also your function as written here doesn't exist. It should be, as mentionned by Dason, either :
testfunc15 = function (state, outcome) or testfunc15 <- function (state, outcome)
And the end could be return(tempdiff) or tempdiff

Resources