RISmedを用いたPubMed検索

RISmedはPubMed検索のためのRのパッケージです。作者はStephanie Kovalchik氏です。ASReview https://asreview.nl/ を用いた文献選定の際には、Title, Abstractのデータを用います。書誌情報と合わせて、これらのデータを含むExcelファイル、またはCSVあるいはRISファイルを用意する必要があります。その際に、RISmedを使うのがひとつの方法です。

PubMedではGETメソッドで直接データベースにアクセスして、検索結果をダウンロードできるe-utilitiesというサービスがあります。MeSHへのAutomatic Term Mappingは適用されません。https://www.ncbi.nlm.nih.gov/books/NBK25501/

それを利用するRのパッケージです。pmSearchも同じサービスを利用しています。

RISmedとtcltk2のパッケージをThe Comprehensive R Archive Network (CRAN)(https://cran.r-project.org/)からRにインストールしておきます。tcltk2は検索結果をCSVファイルとして保存する際のインターフェースとして用います。
Stephanie Kovalchik: RISmed https://cran.r-project.org/web/packages/RISmed/index.html
Philippe Grosjean: tcltk2 https://cran.r-project.org/web/packages/tcltk2/index.html

パッケージがまだインストールされていない場合は、以下のスクリプトをRで実行してください。
#Install the packages.
packneed=c(“RISmed”,”tcltk2″);current=installed.packages();addpack=setdiff(packneed,rownames(current));url=”https://ftp.yz.yamagata-u.ac.jp/pub/cran/”;if(length(addpack)>0){install.packages(addpack,repos=url)};if(length(addpack)==0){print(“Already installed.”)}

以下のRでスクリプトを実行すると検索結果をCSVファイルとして保存できます。SearchWordsと言う変数に検索式search queryを格納しますので、””で囲んであるところを書き換えて使用してください。すべてを選択して、実行すると、ファイル保存のダイアログまで実行されます。ResultsData=EUtilsGet(Results, type=”efetch”, db=”pubmed”)の実行に時間がかかります。

保存したCSVファイルを直接開くのではなく、Excelを起動して、データメニューからテキストまたはCSVファイルからインポートします。元のファイルはUTF-8でエンコードされており、Shift JISがデフォルトのExcelでは文字化けするので、そのような手順を取ります。ファイル保存の際は.xlsxにすることもできます。

また、CSVファイルはテキストファイルなので、Notepad++ https://notepad-plus-plus.org/ などで一度開いて、エンコーディングをUTF-8-BOMに変換するとExcleで直接開いても文字化けしません。

図 Excleで取り込んで.x.sxファイルとして保存したPubMed検索結果。

以下にR用のスクリプトを示します。
library(“RISmed”)
library(“tcltk2”)

#Make a search query for PubMed. Write your query in ” “.

SearchWords=”(junior doctor OR young doctor OR resident physician OR intern) AND mindfulness AND humans[mh] AND (english[la] OR japanese[la]) AND hasabstract[tw] AND 2024[dp]”

#Connect and retrieve a list of PubMed IDs. You can change retmax and set years asmindate=2000, maxdate=2024, retmax=2000

Results=EUtilsSummary(SearchWords, type=”esearch”, db=”pubmed”, retmax=2000)

#Show the number of citations retrieved and get title, abstract and other data. This step takes time.

QueryCount(Results)
ResultsData=EUtilsGet(Results, type=”efetch”, db=”pubmed”)

#Make publication year list.

year=YearEntrez(ResultsData)

#Make a list of authors (Last name + initials) for each citation and a list of reference id (first author + year).

au=Author(ResultsData)
refn=length(au)
auv=rep(“”,refn)
refidv=rep(“”,refn)
for(i in 1:refn){
authors=cbind(au[[i]]$LastName,au[[i]]$Initials)
ma=nrow(authors)
authors[1,]
paste(authors[1,1],authors[1,2])

aul=””
for(j in 1:ma){
aut=paste(authors[j,1],authors[j,2])
aul=paste(aul,aut,sep=”, “)
}
aul=substr(aul,3,nchar(aul))
auv[i]=aul
refidv[i]=paste(authors[1,1],authors[1,2],year[i])
}

#Make citation list. No formatting. Including DOI information.
refer=Citations(ResultsData)

cite=rep(“”,refn)
for(i in 1:refn){
cite[i]=refer[[2]][[i]]
}

#Create a data frame of PMID, Reference_ID,Citation,Year, Title,Abstract. Citation format is not modified.

pubmed_data=data.frame(‘PMID’=PMID(ResultsData),’Reference_ID’=refidv,’Citation’=cite, ‘Year’=YearEntrez(ResultsData), ‘Title’=ArticleTitle(ResultsData), ‘Abstract’=AbstractText(ResultsData))

#Save the frame work as a CSV file with a save file dialogue. Add file extension “.csv”.

filnam=tclvalue(tkgetSaveFile(initialfile=”export.csv”,filetypes=”{{CSV Files} {.csv}} {{All files} *}”));if(filnam!=”.csv”){write.csv(pubmed_data,filnam,row.names=FALSE)}

#Do not open the file directly to avoid character encoding trouble. Launch Excel, then from Data menu use import text/csv file.
#The saved file is a text file with UTF-8. You can change encoding from UTF-8 to UTF-8-BOM using Notpad++, and you can directly open the file with Excel without garbles.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

JPEG PNG TIFF file attached

This site uses Akismet to reduce spam. Learn how your comment data is processed.