In this paper of the new kid, looks like a lot of medical small lovely will use some similar Perl script language, some professional R language is higher but more partial of the language, I have a little cute, sprout new need to use Perl to download them from the TCGA database for data format translation process, the late R language will be used for statistical analysis.

Back to the basics, this article focuses on the various tramps installed for the Perl interpreter environment, and will be explored later when using THE R language. Throughout the major forums, in fact, detailed articles, especially Perl execution script interpreter environment dependency installation is very few, and related articles are relatively old, some even 10 years ago turned out about a few of the reference value of the article, is posted, for interested in children’s shoe reference.

Because my operating platform is windows10, and the operating platform of the new kids is macOS, so the information is divided into two systems for reference. Now the article is divided into two categories, as follows:

Installation of Perl GD module for Linux/Windows/MAC (Windows, macOS)

Perl’s official website (Windows, macOS)

Perl official download address (Windows, macOS)

Cpan official website (Windows, macOS)

Three ways to install Perl modules (Windows, macOS)

Perl PPM Installation module (Windows)

Install JSON module in Perl for MAC (macOS)

Installing perl modules on Mac OSX 10.7.3 (macOS)

MAC installed perl: blog.csdn.net/yuxin6866/a… (macOS)

Configuring Perl on a new Mac (macOS)

Homebrew (macOS)

After climbing the pit for a day, I sorted out the harvest and shared it with you:

1. Download and install the Perl interpreter

  • download

Perl(general MacOS X has already installed Perl, but the version is not determined, do not know whether the version is too old, Windows system requires you to go to the official website to download the installation, the MAC can also go to the official website download), through the Perl official website, as shown below:

There are two download and installation modes for Windows: ActiveState Perl. The following figure shows the ActiveState download mode for Windows.

Another way to install Windows is Strawberry Perl.

Note: The ActiveState Perl approach was shipped with PPM by default in previous versions of Perl before 5.26. Including version 5.26, PPM is now installed without the tool by default, and many packages will no longer be built for earlier versions of ActivePerl. If you want to install perl packages, you need to install them in CPAN mode, the same way macOS installs Perl packages. If Strawberry Perl is installed, if you want to install the Perl package, you also need to install it through CPAN.

After Windows is downloaded, the installation package is.msi ending

To install macOS, log in to the following page and select Download Builds

The downloaded installation package ends in. PKG.

  • The installation

Installation Click the installation package to install.

After Windows is installed, the picture is as follows (version 5.26 has no PPM).

If you install activePerl with PPM, you can use PPM to search for relevant modules (packages), such as JSON modules, if you install activePerl with a higher version that does not support PPM or if you install Strawberry Perl without PPM. You need to install some Perl modules (packages) using CPAN.

2. Install related Perl packages

The purpose of installing the Perl interpreter is to perform basic scripting functions, but also to rely on its various packages and modules to process data such as cancer-related data downloaded from TCGA and added to CART, as shown below:

Inside the data format is not what we want, we want to build the data generator matrix format, you need to do processing through Perl, the following steps to deal with, first of all we need to download each folder. Unity gz files in a folder, if the file is less, can also be manually paste, But if you have dozens or hundreds of files, manual pasting and copying is the dumbest way to do it, so you can use tools and Perl scripts to do this tedious and pointless work.

  • First, let’s check that the Perl we just installed was installed successfully

Open the terminal, Windows students, Win + R, call up the run box (lower left corner), enter CMD, the command prompt will appear, as shown below

Enter the command:

perl -v
Copy the code

If the Information about the Perl version is displayed, the installation is successful. If the information is not displayed or an error message is displayed, the installation is not successful.

MacOS opens the terminal as follows:

Open search by command + space and then enter terminal to open terminalCopy the code

Enter the command in the terminal:

perl -v
Copy the code

If the perl version information is not displayed or an error is reported, the installation is not successful.

  • Install perl-related dependency package methods

Because a cute new shoe is a macOS operating system, and the related environment of Windows installation dependency package is a bit troublesome, it seems to need to be handled manually, so I only sort out the related steps of macOS installation environment, as follows:

1. Install Xcode first

Xcode is an integrated development tool that runs on The Mac OS X operating system. Xcode is not installed so that you can write code using the IDE. Xcode is not available in the perl environment as a whole, but it will cause an error if you do not install Xcode using the macOS command line tool Homebrew. There is also a way to use Homebrew without installing Xcode, but it’s a bit of a hassle

Note: the installation package is a bit large, down 11 G, feel free to download completed.

The installation steps are as follows:

Search the App Store for Your Mac and download Xcode. The icon looks like this:

2. Open Xcode once

(For initialization purposes, note: If your computer has a low configuration, do not open Xcode after opening it once, even if you use Perl or the command line tool Homebrew again. Otherwise, your computer’s memory will explode and you will not be able to do anything. Its mission is only the first time, do some initial configuration.

3. After installing Xcode, open the terminal.

Open terminal Method: Run **command + space to open search, and then enter terminal** to open terminal.

Enter the following command in the terminal:

xcode-select --install
Copy the code

Select Install all the time.

4. Install the cli tool Homebrew and continue to run the following commands on the terminal:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Copy the code

Note: Installing Homebrew directly from a foreign source will be very slow or even unsuccessful. The command above has been replaced with a domestic source.

After executing the command, install as prompted.

5. Install the latest Perl 5.30 (no Perl 6…) (Skip this step if a MAC is installed.)

Note: Because Perl comes with the MAC, you can try not to install the latest version of Perl, skip step 5, if the following steps fail, you can go back to step 5 and install the latest version of Perl, but there is a version of Perl itself, so it may cause problems. Therefore, if you are not sure whether the installed version can be used, skip step 5.

Install Perl with the following command:

brew install perl
Copy the code

This command installs Perl through the command line tool Homebrew.

Once the installation is complete, verify the version of Perl you are currently using by using the following command from your terminal:

perl -v
Copy the code

If it is still the original version, check the introduction and type the command in terminal:

Where is perl
Copy the code

You should see /usr/local/bin/perl before /usr/bin/perl and pointing to

/usr/local/Cellar/perl/{version}/bin/perl.

6. Install Cpanm

This step gets to the business of installing Perl’s package management tool, Cpanm.

Cpanm is an upgraded version of CPAN.

Enter the following command on the terminal:

brew install cpanm
Copy the code

7. Use cPANM to install the JSON package

Enter the following command on the terminal:

sudo cpanm install JSON
Copy the code

That is, the JSON package is installed.

3. Use Perl to process data

The relevant data downloaded from TCGA are as follows:

Once inside the folder

What we need to deal with is the.gz files in each folder, formatted into a matrix of data

1. We first need to put all the.gz files in the folder into one folder

Can be manually pasted into a folder, more than one will be cumbersome. Next, let’s use a Perl script to help us tidy up.

  • Create putFilestoonedir.pl file

We can create a putFilestoonedir.pl file ending in.pl and place it in the same directory as the folder we want to work with, as shown below

The putFilestoonedir.pl file code is as follows:

use strict; use warnings; use File::Copy; my $newDir="files"; unless(-d $newDir) { mkdir $newDir or die $! ; } my @allFiles=glob("*"); foreach my $subDir(@allFiles) { if((-d $subDir) && ($subDir ne $newDir)) { opendir(SUB,"./$subDir") or die $! ; while(my $file=readdir(SUB)) { if($file=~/\.gz$/) { #`cp ./$subDir/$file ./$newDir`; copy("$subDir/$file","$newDir") or die "Copy failed: $!" ; } } close(SUB); }}Copy the code
  • Use the terminal to execute the putFilestoonedir.pl script file in the target folder

Enter the putFilestooneDir.pl folder as follows:

After entering the target folder, run the following command:

perl putFilesToOneDir.pl
Copy the code

After execution, a folder of files will be generated in the same directory as putFilestoonedir.pl, as shown in the following figure

Go to the files folder and the content is as follows

All.gz files have been copied into the files folder.

The article that inspired me above is this one:

TCGA database after download file merge and conversion